feat(sveltekit): Ensure AsyncLocalStorage async context strategy is used in Cloudflare Pages#15557
Merged
feat(sveltekit): Ensure AsyncLocalStorage async context strategy is used in Cloudflare Pages#15557
AsyncLocalStorage async context strategy is used in Cloudflare Pages#15557Conversation
…d in cloudflare pages
AsyncLocalStorage async context strategy is used in Cloudflare Pages
AbhiPrasad
approved these changes
Mar 3, 2025
Contributor
AbhiPrasad
left a comment
There was a problem hiding this comment.
Keeping it as public API feels fine to me because of all the use cases, lets do it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While investigating #15506, I noticed that we missed an important part when setting up the SDK via the
initCloudflareSentryHandlehook: We need to call@sentry/cloudflare'ssetAsyncLocalStorageAsyncContextStrategyfunction as otherwise, we don't get working request isolation.I decided to export
setAsyncLocalStorageAsyncContextStrategyfrom@sentry/cloudflareso that we could otherwise only callsentryPagesPluginand completely ignore the return value. Which isn't ideal as we add public API. However,initCloudflareSentryHandleis basically a SvelteKit-specific version ofSentryPagesPluginalready, 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:
setAsyncLocalStorageAsyncContextStrategyfrom@sentry/cloudflare/internalsentryPagesPluginand completely ignore the return typeHappy to make any of these changes.
Otherwise, the PR adds tests and refactors the test directory structure after #13142.
note:
featbecause public API is added to cloudflare package