Skip to content
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

fix(cloudflare)!: add better type handling for additional context #15276

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

chanceaclark
Copy link

@chanceaclark chanceaclark commented Feb 3, 2025

What/Why?

Adds better handling of Cloudflare context for types. Using any and unknown in an interface was causing type mismatch, so even though it's more verbose, we should match the types needed from Cloudflare:
Screenshot 2025-02-03 at 12 11 58

Noticed a v9 is coming soon, so thought it's a good opportunity to add a BC now.

BREAKING CHANGE:
Updates the cloudflare withSentry handler generic type to allow passing in additional types used by ExportedHandler.

Before:

Sentry.withSentry<ExportedHandler<Env>>(...)

After:

Sentry.withSentry<Env>(...)

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

Screenshot 2025-02-03 at 12 18 28

BREAKING CHANGE:
Updates the cloudflare withSentry handler generic type to allow passing in additional
types used by ExportedHandler.

Before:
```
Sentry.withSentry<ExportedHandler<Env>>(...)
```

After:
```
Sentry.withSentry<Env>(...)
```
@chanceaclark chanceaclark marked this pull request as ready for review February 3, 2025 17:23
@Lms24
Copy link
Member

Lms24 commented Feb 6, 2025

Hi @chanceaclark thanks for opening this PR! Would you mind sharing a reproducible example where you get a type error with the currently typed withSentry function? Ideally, we find a way to avoid the breaking change because our usual process around breaking changes is to deprecate an existing API for a while before we introduce the breaking change.

If we can understand the concrete use case better, we can make a better decision how to proceed with this PR.

Maybe a way forward is also to export a new API with the adjusted types if we can't avoid breaking. We'll see.

@Lms24
Copy link
Member

Lms24 commented Feb 6, 2025

By the way, we have an e2e test application in the repo. Feel free to add another handler that would throw the type error with the current type definition. This can help us understand the problem and at the same time adds a regression test, thanks :)

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.

2 participants