Skip to content

[vitest-pool-workers] Dispatch RPC methods through proxied Durable Object instances#14070

Merged
dario-piotrowicz merged 2 commits into
cloudflare:mainfrom
dmmulroy:fix/vitest-pool-proxied-durable-object-rpc
May 28, 2026
Merged

[vitest-pool-workers] Dispatch RPC methods through proxied Durable Object instances#14070
dario-piotrowicz merged 2 commits into
cloudflare:mainfrom
dmmulroy:fix/vitest-pool-proxied-durable-object-rpc

Conversation

@dmmulroy

@dmmulroy dmmulroy commented May 27, 2026

Copy link
Copy Markdown
Contributor

A Durable Object export may return a Proxy from its constructor to mediate public RPC method access, for example to bind wrapped methods to the original instance. @cloudflare/vitest-pool-workers currently validates and retrieves RPC methods directly from the constructor prototype, then binds the raw method to the returned proxy. This bypasses the proxy's get trap and causes methods using ECMAScript private fields or methods to throw a receiver-brand TypeError.

This changes Durable Object RPC resolution to continue validating prototype visibility first, but then retrieve an allowed method through the constructed instance so proxy wrappers can mediate it. Constructor-assigned own overrides remain rejected, matching native workerd behavior rather than exposing arbitrary instance methods.

The RPC fixture now covers:

  • a Durable Object constructor returning a proxy that binds a prototype RPC method which reads a private field; and
  • rejection of a constructor-assigned override for an otherwise prototype-visible method.

I additionally checked both behaviors through wrangler dev/native workerd: the proxy-mediated private-field method succeeds, while the constructor-assigned method override is rejected.


  • 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: this fixes Vitest pool emulation of existing Durable Object RPC behavior and does not introduce a public API or configuration option.

A picture of a cute animal (not mandatory, but encouraged)

48513394-34DD-4B33-B27B-5B2B472B5E1E_1_105_c
Open in Devin Review

@dmmulroy dmmulroy requested a review from workers-devprod as a code owner May 27, 2026 21:08
@changeset-bot

changeset-bot Bot commented May 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0057484

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/vitest-pool-workers 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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk May 27, 2026
@workers-devprod workers-devprod requested review from a team and dario-piotrowicz and removed request for a team May 27, 2026 21:08
@workers-devprod

workers-devprod commented May 27, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@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: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented May 27, 2026

Copy link
Copy Markdown
create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14070

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 0057484

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🙂

@workers-devprod workers-devprod 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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk May 27, 2026
@dario-piotrowicz dario-piotrowicz merged commit 96ae856 into cloudflare:main May 28, 2026
68 of 71 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants