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

feat(sveltekit): Ensure AsyncLocalStorage async context strategy is used in Cloudflare Pages #15557

Merged
merged 2 commits into from
Mar 3, 2025

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 3, 2025

While investigating #15506, I noticed that we missed an important part when setting up the SDK via the initCloudflareSentryHandle hook: We need to call @sentry/cloudflare's setAsyncLocalStorageAsyncContextStrategy function as otherwise, we don't get working request isolation.

I decided to export setAsyncLocalStorageAsyncContextStrategy from @sentry/cloudflare so that we could otherwise only call sentryPagesPlugin and completely ignore the return value. Which isn't ideal as we add public API. However, initCloudflareSentryHandle is basically a SvelteKit-specific version of SentryPagesPlugin already, so I think it's fine to just set the ACS in there as well.

If reviewers prefer though, I think we can solve this in other ways:

  1. export setAsyncLocalStorageAsyncContextStrategy from @sentry/cloudflare/internal
  2. call sentryPagesPlugin and completely ignore the return type

Happy to make any of these changes.

Otherwise, the PR adds tests and refactors the test directory structure after #13142.

note: feat because public API is added to cloudflare package

@Lms24 Lms24 changed the title feat(sveltekit): Ensure AsyncLocalStorage AsyncContextStrategy is used in cloudflare pages feat(sveltekit): Ensure AsyncLocalStorage async context strategy is used in Cloudflare Pages Mar 3, 2025
@Lms24 Lms24 self-assigned this Mar 3, 2025
@Lms24 Lms24 requested a review from AbhiPrasad March 3, 2025 13:17
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Keeping it as public API feels fine to me because of all the use cases, lets do it.

@Lms24 Lms24 merged commit 288a366 into develop Mar 3, 2025
33 checks passed
@Lms24 Lms24 deleted the lms/fix-sveltekit-cf-acs branch March 3, 2025 15:42
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