fix(nextjs): Use Next.js internal AsyncStorage#7630
Merged
Conversation
Contributor
size-limit report 📦
|
AbhiPrasad
approved these changes
Mar 28, 2023
| let sentryTraceHeader: string | undefined | null = undefined; | ||
| let baggageHeader: string | undefined | null = undefined; | ||
|
|
||
| // TODO: Explain this try catch |
| NEXTJS_REQUEST_ASYNC_STORAGE_MODULE_PATH, | ||
| ); | ||
| } else { | ||
| templateCode = templateCode.replace(/__SENTRY_NEXTJS_REQUEST_ASYNC_STORAGE_SHIM__/g, requestAsyncStorageShimPath); |
Contributor
There was a problem hiding this comment.
l: Instead of warning at runtime, can we add a warning here instead?
| // Needs to end in .cjs in order for the `commonjs` plugin to pick it up | ||
| const WRAPPING_TARGET_MODULE_NAME = '__SENTRY_WRAPPING_TARGET_FILE__.cjs'; | ||
|
|
||
| const NEXTJS_REQUEST_ASYNC_STORAGE_MODULE_PATH = 'next/dist/client/components/request-async-storage'; |
Contributor
There was a problem hiding this comment.
let's link to GH sha w/ with filename?
3 tasks
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.
Fixes #7562
Somewhat building on 9ab0772, we cannot use Next.js'
headers()function in our server components wrapping because it will trigger an error stating that "dynamic functions" cannot be used in static components.We fix this by directly using the
RequestAsyncStoragethat Next.js exports. This will circumvent the error-generating code. Unfortunately, this export is not part of the public API so we had to add some additional handling in case the export should ever disappear.This change is tested implicitly by our E2E tests that test for connected traces in server components.