Repository navigation
[miniflare] List Durable Object IDs only by class name - #17133
edmundhung wants to merge 3 commits into
Conversation
|
LGTM |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
listDurableObjectIds() takes the class name and the Worker that exports it, so a binding that shares a class's name can't make it list another class. Wrangler's test harness resolves a binding name to its class first, as its other Durable Object helpers do, and the Vitest plugin passes the class its binding designates.
84dc339 to
15bbd14
Compare
🦋 Changeset detectedLatest commit: de7008a The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
There was a problem hiding this comment.
Superseded by the review of
9fe2c360.
This review, of 15bbd14c
💬 Approved with comments — The change is consistent across Miniflare, Wrangler and the Vitest plugin. The only notes are informational: missing consumer-level tests and one imprecise sentence in the changeset.
Findings: 2 info (2 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 info
The changes are consistent across all three packages. Nothing tests the fixed case at the consumer level.
Recommendation: 💬 Optional Nits
- [INFO] No consumer-level test covers a binding whose name matches a different exported class. (
packages/vitest-plugin/src/worker/durable-objects.ts:268)
View full review
- Consumer tests. The Miniflare spec covers the new class-only signature and checks that a binding name is rejected. The Vitest plugin and Wrangler harness now resolve the class themselves, but neither has a test for the case this pull request fixes: a binding named after a different exported class. Both code paths read correctly. The Vitest designator lookup and Wrangler's
resolveDurableObjectTargeteach pass Miniflare the class and Worker pair its new contract expects.
📝 Documentation: 💬 1 info
The changeset slightly overstates when a binding name throws.
Recommendation: 💬 Optional Nits
- [INFO] The changeset says a binding name throws, but a binding name that is also an exported class name is still accepted. (
.changeset/miniflare-list-do-ids-by-class.md:7)
View full review
- The changeset says a binding name now throws.
listDurableObjectIds()still accepts any string that matches a Durable Object class the Worker exports, even when that string is also a binding name.
Reviewed commit: 15bbd14c
… list listDurableObjectIds() resolves a binding name before a class name, as Miniflare did when it took either, and returns no IDs for a binding to a Worker the harness doesn't run, so Wrangler's harness lists what it did before.
There was a problem hiding this comment.
Superseded by the review of
de7008a3.
This review, of 9fe2c360
💬 Approved with comments — The class-only contract is applied consistently across Miniflare, the Vitest plugin and Wrangler's harness. The only notes are informational: one consumer-level test gap, a difference in name-resolution order inside the Wrangler harness, and one imprecise sentence in the changeset.
Findings: 3 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 2 info
The change is consistent. Two informational notes: a consumer test gap, and the Wrangler harness resolving names in a different order for listing than for its other Durable Object helpers.
Recommendation: 💬 Optional Nits
- [INFO] No consumer-level test covers a binding whose name matches a different exported class. (
packages/vitest-plugin/src/worker/durable-objects.ts:268) - [INFO] The harness's listDurableObjectIds checks binding names before class names, while resolveDurableObjectTarget (used by the storage and evict helpers) checks class names first. (
packages/wrangler/src/api/test-harness.ts:1174)
View full review
- Consumer tests. The Miniflare spec covers the class-only signature. Neither the Vitest plugin nor Wrangler's harness tests a binding named after a different exported class, which is the case this pull request is about. The Wrangler e2e test only uses
COUNTERandCounter, and both resolve to the same class. - Resolution order in the Wrangler harness. The new
listDurableObjectIdscode inpackages/wrangler/src/api/test-harness.tslooks up a binding name first and an exported class second.resolveDurableObjectTarget(lines 758-803), which the storage and evict helpers use, does it the other way round: class first, binding name last. If a binding's name matches a different exported class, listing returns the binding's class while storage and evict act on the exported class. The second commit says this keeps the earlier behaviour on purpose, so it is not a regression. It does mean the harness keeps the ambiguity this pull request removes from Miniflare, and the resolution logic now lives in two places.
📝 Documentation: 💬 1 info
The changeset slightly overstates when a binding name is rejected.
Recommendation: 💬 Optional Nits
- [INFO] The changeset says a binding name throws, but a binding name that is also an exported class name is still accepted. (
.changeset/miniflare-list-do-ids-by-class.md:7)
View full review
.changeset/miniflare-list-do-ids-by-class.md:7says a binding name now throws. A name that is both a binding name and the name of an exported Durable Object class is still accepted, and it is treated as the class.
Reviewed commit: 9fe2c360
listDurableObjectIds() looks the name up in the bindings with the test's bindingOverrides applied, as Miniflare did, and the changeset says which binding names now throw.
There was a problem hiding this comment.
💬 Approved with comments — Miniflare, the Vitest plugin and Wrangler's harness all follow the class-only contract consistently. One informational note remains: the Wrangler harness resolves names in a different order for listing than for storage and eviction.
Findings: 1 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 info
The class-only contract is applied consistently. One INFO note remains about resolution order in the Wrangler harness.
Recommendation: 💬 Optional Nits
- [INFO] Harness listDurableObjectIds resolves the binding name before the class name, while resolveDurableObjectTarget (used by the storage and evict helpers) checks the class name first. (
packages/wrangler/src/api/test-harness.ts:1172)
View full review
- Resolution order in the Wrangler harness.
listDurableObjectIdsinpackages/wrangler/src/api/test-harness.tslooks up a binding name in the applied bindings first, then falls back to a class name.resolveDurableObjectTarget, which the storage and evict helpers use, checks class names first.- If a binding's name matches a different exported class, listing targets the binding's class while storage and evict act on the exported class.
- The commit message says the earlier harness behaviour is kept on purpose, so this is not a regression. The resolution logic does now live in two places.
- Checked, no issue found:
- The Vitest worker sends
designator.classNameanddesignator.scriptName ?? selfName. - The loopback parameter rename to
class_namematches its caller. - The Miniflare spec covers the new signature and the rejection of binding names.
- The Vitest worker sends
- One earlier informational note (no consumer-level test for a binding named after a different exported class) is still open. Its code has not changed, so it is not repeated here.
✅ All other checks passed
🚀 Release: ✅ LGTM
Overall risk: Medium. Miniflare's listDurableObjectIds() now accepts only class names, which breaks callers that pass a binding name. The changeset documents this and explains how to migrate. The caller-facing APIs of the Vitest plugin and Wrangler's harness do not change.
🔒 Security: ✅ LGTM
Narrowing listDurableObjectIds to class names keeps Miniflare's check that the Worker exports the class. A binding's script_name can no longer redirect the call.
📖 AGENTS.md: ✅ LGTM
No issues found.
⚡ Performance: ✅ LGTM
The only added work is one small scan over session.devEnvs per list call, and its cost is negligible.
📝 Documentation: ✅ LGTM
The reworded changeset now says a binding name throws unless the Worker also exports a class with that name. That matches the behaviour.
Reviewed commit: de7008a3
Currently
miniflare.listDurableObjectIds()accept either the class name or a binding name, while the storage and evict helpers accepts the class name only.This updates it to take only the class name and the Worker that exports it. This is a breaking change to miniflare but I think it should be fine given it is still on v5 beta. All existing consumers, like Wrangler's
createTestHarness()and the vitest plugin will resolve a binding name to its class first, so their users could keep passing the binding name as they do today.listDurableObjectIds()isn't in the public docs, and the Vitest plugin's and Wrangler's APIs don't change