Comments (3)
Can you give a code example that doesn't work @mikecann? I just tried it and it seems to work just fine?
const id = ns.newUniqueId()
const stub = ns.get(id)
console.log(stub.id.toString())
from miniflare.
import { router } from "./routes";
export { UserAggregate } from "./aggregates/user/UserAggregate";
export interface EnvInterface {
UserAggregate: DurableObjectNamespace;
}
export default {
async fetch(request: Request, env: EnvInterface): Promise<Response> {
console.log(`TEST`, env.UserAggregate.newUniqueId());
return new Response(`done`);
},
};
Outputs: TEST DurableObjectId { name: undefined }
I am using esbuild to bundle my worker:
import { build } from "esbuild";
const isWatchMode = () => false;
const config = {};
async function bootstrap() {
console.log(`starting`, config);
await build({
entryPoints: ["./src/index.ts"],
bundle: true,
format: "esm",
outdir: `dist`,
outExtension: { ".js": ".mjs" },
sourcemap: "external",
platform: "node",
target: [`node14`],
external: [],
watch: isWatchMode()
? {
onRebuild(err, result) {
if (err) console.error("watch build failed:", err);
else console.log("watch build succeeded");
},
}
: undefined,
// banner: {
// js: constructServerBannerEnvInjection(getBTEnvVarsForBannerInjection()),
// },
});
console.log(`build complete`);
}
bootstrap()
.then(() => {
if (!isWatchMode()) {
console.log(`build done, exiting now.`);
process.exit(0);
}
})
.catch(e => {
console.error(e);
process.exit(1);
});
from miniflare.
scratch that sorry if I do toString()
on the ID I get 000000017b4cc362ba6844a4e72bc0cffedebbdcbc9fbd16762ae91aa9b85edb
. Apologies for the confusion!
from miniflare.
Related Issues (20)
- Update undici dependency due to vulnerability HOT 1
- [Docs] Miniflare v2 docs removed? HOT 3
- How to migrate Jest unit tests to Miniflare V3? HOT 1
- Support for typescript. HOT 1
- Is is it possible to collect coverage with vitest-environment-miniflare? HOT 2
- Increase better-sqlite3 compatibility HOT 1
- Uncaught error when initializing two top level WASM modules
- Multiple nodejs_compat packages missing (`crypto`, `path`, etc) HOT 4
- Fix CVE-2024-24758 HOT 3
- Type confusion HOT 1
- @miniflare/shared should not depend on @types/better-sqlite3 HOT 1
- Vitest bug: "Error: ENOENT: no such file or directory" HOT 2
- Workers: Error when an undefined value is exported in dev environment
- Type incompatibility issue between miniflare and workers-types HOT 4
- BUG: cannot install this library in node 22, please update better-sqlite3 HOT 1
- MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. HOT 7
- How to test with `nodejs_compat` workers?
- How to use Worker's new native RPC feature? HOT 3
- Support for rate limiting HOT 1
- Bug in Put Conditional? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miniflare.