Skip to content

[miniflare] List Durable Object IDs only by class name - #17133

Open
edmundhung wants to merge 3 commits into
mainfrom
edmundhung/miniflare-list-do-ids-by-export
Open

edmundhung wants to merge 3 commits into
mainfrom
edmundhung/miniflare-list-do-ids-by-export

Conversation

@edmundhung

@edmundhung edmundhung commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

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.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Miniflare's listDurableObjectIds() isn't in the public docs, and the Vitest plugin's and Wrangler's APIs don't change

@ask-bonk

ask-bonk Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@17133

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@17133

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@17133

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@17133

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@17133

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@17133

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@17133

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@17133

miniflare

npm i https://pkg.pr.new/miniflare@17133

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@17133

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@17133

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@17133

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@17133

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@17133

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@17133

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@17133

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@17133

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@17133

wrangler

npm i https://pkg.pr.new/wrangler@17133

commit: de7008a

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.
@edmundhung
edmundhung force-pushed the edmundhung/miniflare-list-do-ids-by-export branch from 84dc339 to 15bbd14 Compare November 23, 2026 16:50
@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: de7008a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
miniflare Minor
@cloudflare/deploy-helpers Patch
@cloudflare/dev-helpers Patch
@cloudflare/pages-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch
wrangler Patch

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

@edmundhung
edmundhung marked this pull request as ready for review November 23, 2026 16:51
@workers-devprod
workers-devprod requested review from a team and jamesopstad and removed request for a team November 23, 2026 16:52
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/miniflare-list-do-ids-by-class.md: [@cloudflare/wrangler]
  • packages/miniflare/src/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/test/plugins/do/index.spec.ts: [@cloudflare/wrangler]
  • packages/vitest-plugin/src/pool/loopback.ts: [@cloudflare/wrangler]
  • packages/vitest-plugin/src/worker/durable-objects.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/test-harness.ts: [@cloudflare/wrangler]

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 resolveDurableObjectTarget each 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

@edmundhung edmundhung changed the title [miniflare] List Durable Object IDs by the class the Worker exports [miniflare] List Durable Object IDs only by class name Nov 23, 2026

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 3 potential issues.

Devin Review

… 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.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 COUNTER and Counter, and both resolve to the same class.
  • Resolution order in the Wrangler harness. The new listDurableObjectIds code in packages/wrangler/src/api/test-harness.ts looks 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:7 says 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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

Devin Review

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.

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 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.
    • listDurableObjectIds in packages/wrangler/src/api/test-harness.ts looks 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.className and designator.scriptName ?? selfName.
    • The loopback parameter rename to class_name matches its caller.
    • The Miniflare spec covers the new signature and the rejection of binding names.
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants