-
Notifications
You must be signed in to change notification settings - Fork 985
Add Miniflare & Wrangler support for unbound Durable Objects #10596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: f1105de The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
654af9f
to
21d5739
Compare
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the Depending on your changes, running Notes:
|
9829be6
to
eb271e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Non-blocking question: The alternative approach would be to collect all the DOs in the same way (by storage) and then collect the bindings for those that have them. Would that also work or not?
packages/miniflare/src/index.ts
Outdated
).map((workerDODesignator) => { | ||
const doInfo = normaliseDurableObject(workerDODesignator); | ||
if (doInfo.serviceName === undefined) { | ||
// Fallback to current worker service if name not defined | ||
doInfo.serviceName = workerServiceName; | ||
} | ||
return { | ||
doInfo, | ||
workerRawName: workerOpts.core.name, | ||
}; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly the same as the map
callback above. Could we combine before mapping e.g. [...Object.values(workerOpts.do.durableObjects ?? {}), ...(workerOpts.do.additionalUnboundDurableObjects ?? [])].map()
. Either that or extract the callback into a function that's reused.
In theory, yes, and I initially tried that approach. However, it ended up being much more invasive across Miniflare/Vite/Vitest since all of those assume in various places that the durable object config is a record of binding name to config. This approach seemed like a much simpler option to reduce the added complexity |
2fd34ff
to
d9477b7
Compare
Co-authored-by: James Opstad <[email protected]>
Co-authored-by: James Opstad <[email protected]>
Co-authored-by: James Opstad <[email protected]>
Fixes #10294