Skip to content

fix(cloudflare): Instrument custom WorkerEntrypoint RPC methods#22310

Open
akshitsinha wants to merge 4 commits into
getsentry:developfrom
akshitsinha:fix/cloudflare-worker-entrypoint-rpc
Open

fix(cloudflare): Instrument custom WorkerEntrypoint RPC methods#22310
akshitsinha wants to merge 4 commits into
getsentry:developfrom
akshitsinha:fix/cloudflare-worker-entrypoint-rpc

Conversation

@akshitsinha

@akshitsinha akshitsinha commented Jul 16, 2026

Copy link
Copy Markdown

withSentry() only wraps the lifecycle handlers on WorkerEntrypoint (fetch, scheduled, queue, tail). Custom RPC methods never get wrapped, so errors thrown in them are not captured and trace propagation does not work for them.

This mirrors what we already do for Durable Objects in durableobject.ts: the constructor proxy returns an instance proxy that catches RPC methods as workerd accesses them, and wraps them using the same wrapMethodWithSentry helper.

The generic typing change on instrumentWorkerEntrypoint / WorkerEntrypointConstructor also fixes #22233, where the Env generic was ignored and the constructor parameter was always typed as the global cloudflareEnv.

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
  • Link an issue if there is one related to your pull request. If no issue is linked, one will be auto-generated and linked.

Also fixes #22233

@akshitsinha
akshitsinha force-pushed the fix/cloudflare-worker-entrypoint-rpc branch from 622dc60 to 76d20e4 Compare July 16, 2026 07:26
@akshitsinha
akshitsinha force-pushed the fix/cloudflare-worker-entrypoint-rpc branch from 76d20e4 to feb3ccd Compare July 16, 2026 07:29
@akshitsinha
akshitsinha marked this pull request as ready for review July 16, 2026 08:42
@akshitsinha
akshitsinha requested a review from a team as a code owner July 16, 2026 08:42
@akshitsinha
akshitsinha requested review from JPeer264, isaacs and mydea and removed request for a team July 16, 2026 08:42

@JPeer264 JPeer264 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.

Thanks a lot for the PR. It actually looks pretty good already - I just have couple of comments, nothing critical.

Comment thread CHANGELOG.md Outdated
Comment thread packages/cloudflare/src/wrapMethodWithSentry.ts
Comment thread packages/cloudflare/src/wrapMethodWithSentry.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 792cc85. Configure here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloudflare WorkerEntrypointConstructor ignores its Env generic

2 participants