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(nextjs): Use Next.js internal AsyncStorage #7630
Conversation
size-limit report 📦
|
let sentryTraceHeader: string | undefined | null = undefined; | ||
let baggageHeader: string | undefined | null = undefined; | ||
|
||
// TODO: Explain this try catch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still a todo?
NEXTJS_REQUEST_ASYNC_STORAGE_MODULE_PATH, | ||
); | ||
} else { | ||
templateCode = templateCode.replace(/__SENTRY_NEXTJS_REQUEST_ASYNC_STORAGE_SHIM__/g, requestAsyncStorageShimPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's link to GH sha w/ with filename?
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
RequestAsyncStorage
that 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.