Skip to content

feat(cloudflare): Support rpc trace propagation for WorkerEntrypoint#20523

Open
JPeer264 wants to merge 2 commits intodevelopfrom
jp/support-workerentrypoint-entirely
Open

feat(cloudflare): Support rpc trace propagation for WorkerEntrypoint#20523
JPeer264 wants to merge 2 commits intodevelopfrom
jp/support-workerentrypoint-entirely

Conversation

@JPeer264
Copy link
Copy Markdown
Member

@JPeer264 JPeer264 commented Apr 27, 2026

closes #15942
closes JS-212

We already have support for WorkerEntrypoint, but they were not yet fully supported because we didn't have trace propagation for them.

This PR basically adds RPC trace propagation (and therefore full support for WorkerEntrypoint) by instrumenting env for the WorkerEntrypoint. The base implementation is pretty straight forward, it is using instrumentEnv and overwrites the env of the entrypoint instance.

The rest are tests and different scenarios showing how it works. Most tests are the same as the normal exported handler tests: worker-do-rpc is the same as workerentrypoint-do-rpc, just with a WorkerEntrypoint rather than the ExportedHandler. The only additional test scenario is worker-workerentrypoint-rpc which showcases if ExportedHandler and WorkerEntrypoint are working out together.

@JPeer264 JPeer264 requested review from nicohrubec and s1gr1d April 27, 2026 08:34
@JPeer264 JPeer264 self-assigned this Apr 27, 2026
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 27, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 26.16 kB - -
@sentry/browser - with treeshaking flags 24.63 kB - -
@sentry/browser (incl. Tracing) 44.13 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 46.34 kB - -
@sentry/browser (incl. Tracing, Profiling) 49.08 kB - -
@sentry/browser (incl. Tracing, Replay) 83.48 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.96 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 88.15 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 100.8 kB - -
@sentry/browser (incl. Feedback) 43.4 kB - -
@sentry/browser (incl. sendFeedback) 30.96 kB - -
@sentry/browser (incl. FeedbackAsync) 36.14 kB - -
@sentry/browser (incl. Metrics) 27.44 kB - -
@sentry/browser (incl. Logs) 27.59 kB - -
@sentry/browser (incl. Metrics & Logs) 28.28 kB - -
@sentry/react 27.9 kB - -
@sentry/react (incl. Tracing) 46.36 kB - -
@sentry/vue 31.03 kB - -
@sentry/vue (incl. Tracing) 45.96 kB - -
@sentry/svelte 26.18 kB - -
CDN Bundle 28.85 kB - -
CDN Bundle (incl. Tracing) 46.91 kB - -
CDN Bundle (incl. Logs, Metrics) 30.27 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 48.03 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 69.35 kB - -
CDN Bundle (incl. Tracing, Replay) 84.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 85.14 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 89.86 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 90.96 kB - -
CDN Bundle - uncompressed 84.55 kB - -
CDN Bundle (incl. Tracing) - uncompressed 140.16 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 88.75 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 143.62 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 212.71 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 257.96 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 261.41 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 271.66 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 275.1 kB - -
@sentry/nextjs (client) 48.85 kB - -
@sentry/sveltekit (client) 44.58 kB - -
@sentry/node-core 59.06 kB +0.02% +8 B 🔺
@sentry/node 170.35 kB +0.01% +9 B 🔺
@sentry/node - without tracing 96.92 kB +0.01% +9 B 🔺
@sentry/aws-serverless 113.78 kB +0.03% +30 B 🔺
@sentry/cloudflare (withSentry) - minified 165.07 kB +0.07% +103 B 🔺
@sentry/cloudflare (withSentry) 417.38 kB +0.07% +278 B 🔺

View base workflow run

@JPeer264 JPeer264 force-pushed the jp/support-workerentrypoint-entirely branch from 7ea2cd5 to ace755b Compare April 27, 2026 09:40
Copy link
Copy Markdown
Member

@nicohrubec nicohrubec left a comment

Choose a reason for hiding this comment

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

Overall looks lgtm, just not sure about the test

const response = await runner.makeRequest<string>('get', '/rpc/hello');
expect(response).toBe('Hello, World!');

await runner.completed();
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.

h: Can we guarantee at this point that we actually get no RPC transaction? I think the runner just terminates as soon as we see the one expected envelope, so if the RPC transaction just arrives later this test will pass fine even though we don't have the behavior we want. If that's the case maybe we can come up with a pattern that makes this stable. Alternatively we could think about removing this E2E app and relying on unit tests to check this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I'll rewrite it and check if both events are arriving but have different trace id's, then we can be 100% sure

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed it to a .fetch RPC. Now we get a second trace and we can be sure the traces are not connected

@github-actions
Copy link
Copy Markdown
Contributor

👋 @s1gr1d — Please review this PR when you get a chance!

@JPeer264 JPeer264 requested a review from a team as a code owner April 30, 2026 18:33
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.

Add support for Cloudflare WorkerEntrypoint

2 participants