Add a way to suppress or modify experimental.clientTraceMetadata in runtime
#86253
Unanswered
logaretm
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the Sentry SDK for Next.js we encountered an issue where we needed to exclude some pages from having tracing meta tags, specifically the ISR pages since those traces will be cached until the
revalidatetime elapses.This causes client-side traces to be attached to the wrong parent trace and breaks the continuation from the server-to-client tracing.
AFAIK, there was no way to reset those meta tags or clear them since they get grabbed very early on in the
app-render:https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/app-render.tsx#L2497-L2500
This means it happens before we had time to check which page component is being rendered. So suppressing them from the tracer's propagation context itself that we control wouldn't work because it would be too late.
Ideally we would like for a way to turn them off or modify them in runtime and allow clearing them:
Now it's tricky since for ISR pages, the response would be cached, but I think turning them off and caching the response is acceptable and is desired either way, the update/set however is perhaps unsafe and maybe we should not tackle it at all since the issue here is about including the tags and excluding them, not updating them.
In other frameworks we could intercept the final HTML in most cases and remove those tags at the server level, something similar can be very helpful here and I think anyone who is building dist. tracing for Next.js will run into this.
Alternatively, Next can make that decision and avoid including the trace meta all together for ISR pages. Maybe for cache invalidation runs, but not for cached runs, either works.
For now as a workaround we just delete those meta tags really early on the client side.
Beta Was this translation helpful? Give feedback.
All reactions