Skip to content

fix(cloudflare): Ensure errors get captured from durable objects #16838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

0xbad0c0d3
Copy link
Contributor

Fix #16786

  • e2e tests for cloudflare workers
  • 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).

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cod1k added 3 commits July 8, 2025 12:18
This commit introduces Durable Object support in the Cloudflare Workers example to enhance functionality and error tracking via Sentry. It removes outdated tests, updates dependencies, configures Playwright for e2e testing, and refines build/test scripts for CI/CD use cases.
Refactor test structure for clarity and maintainability, including renaming test descriptions and adding `afterEach` for cleaning up mocks. Improve instrumentation validation by checking proper handling of prototype methods and method-specific behaviors. Ensure consistent and detailed coverage of Durable Object functionality.
Introduce `instrumentPrototype` to enhance Sentry instrumentation by proxying prototypes and managing method wrapping at a granular level. Improves maintainability and modularity of the code for durable objects.
cursor[bot]

This comment was marked as outdated.

Replaced hardcoded port value with a dynamic variable for better maintainability and consistency. This change ensures the port is defined in a single location, reducing the risk of errors during updates.
@AbhiPrasad
Copy link
Member

nice! @timfish could you help test this change?

@AbhiPrasad AbhiPrasad self-assigned this Jul 8, 2025
@AbhiPrasad AbhiPrasad requested a review from timfish July 8, 2025 13:30
@AbhiPrasad AbhiPrasad changed the title Cloudflare fixes fix(cloudflare): Ensure errors get captured from durable objects Jul 8, 2025
Simplified the prototype instrumentation logic by replacing the manual mapping of methods with proxies. Added tests to ensure prototype methods are properly instrumented and maintain consistency.
@timfish
Copy link
Collaborator

timfish commented Jul 8, 2025

Nice, I'll take a look!

I'm in the process of trying to add more integration tests!

@andreiborza
Copy link
Member

@0xbad0c0d3 as an aside, please email me at my github username -> firstname.lastname at sentry.io if you'd like a free Sentry T-shirt with free shipping. You've already helped us so much and we'd like to send you a little something.

cursor[bot]

This comment was marked as outdated.

Previously, properties added to the Durable Object receiver were not enumerable, writable, or configurable by default. This change ensures these properties have full flexibility, improving compatibility and developer experience.
@timfish
Copy link
Collaborator

timfish commented Jul 8, 2025

Looks like the cloudflare e2e tests skipped. @AbhiPrasad do you know why it skipped those?

In this PR the e2e tests have been changed to use Playwright whereas it should be possible to use cloudflare's test architecture. I am currently struggling to get this working myself so if we get the e2e tests passing with this PR we should still probably merge it anyway and get a fix out.

Ideally I'd like to get to a point where we have a whole suite of cloudflare tests, maybe under ./dev-packages/cloudflare-integration-tests/?

@0xbad0c0d3
Copy link
Contributor Author

Looks like the cloudflare e2e tests skipped. @AbhiPrasad do you know why it skipped those?

In this PR the e2e tests have been changed to use Playwright whereas it should be possible to use cloudflare's test architecture. I am currently struggling to get this working myself so if we get the e2e tests passing with this PR we should still probably merge it anyway and get a fix out.

Ideally I'd like to get to a point where we have a whole suite of cloudflare tests, maybe under ./dev-packages/cloudflare-integration-tests/?

It was skipped due to the package.json sentryTest.optional

@0xbad0c0d3
Copy link
Contributor Author

Tomorrow I will also push ws e2e tests.

@AbhiPrasad
Copy link
Member

Ideally I'd like to get to a point where we have a whole suite of cloudflare tests, maybe under ./dev-packages/cloudflare-integration-tests/?

yeah we should most definitely do this, and just run it separately

cursor[bot]

This comment was marked as outdated.

Implemented WebSocket handling with message reception and connection closure logic, including error recording in Sentry. Updated tests to verify WebSocket behaviors and added the "ws" package for WebSocket functionality.
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.

@sentry/cloudflare not reporting errors thrown from Durable Objects
4 participants