Repository navigation
feat(nextjs): Wait for the resumed part of a document before starting the pageload - #25142
Merged
Merged
Conversation
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.
Builds on #25141.
When a document resumes a prerendered shell, its
sentry-tracetag sits at the start of the resumed part, which arrives after the SDK has started. In a local demo six of seven visits found no tag at init, so the pageload could only link the server trace instead of joining it.The app router pageload now continues whatever tag is in the document, last one wins. In apps with
cacheComponentsenabled, if there is no tag, noServer-Timingtrace and the document is still streaming, it waits for the tag before creating the pageload span. Other apps keep the immediate start: withoutcacheComponentsa tag is either in<head>from the start or never comes, so waiting only held the pageload back. The wait ends atDOMContentLoadedor after 10 seconds. The span still starts at the time origin and gets its children from the performance timeline, so it looks the same as before, only inside the server's trace. No tag by the end of parsing means a fresh trace, which is the fully static case.A client-side navigation during the wait starts the pageload with a fresh trace first, so the navigation ends it like any pageload it interrupts, as today. Started later, the pageload would end the navigation span instead. The pageload keeps the URL the document was loaded with, even if the navigation already changed it.
Waiting was chosen over moving a started span to another trace. That needs core changes and does not work with span streaming once children are flushed. The cost: fetches, errors and clicks between SDK start and the resumed part are not attached to the pageload. The
Server-Timingfollow-ups (JS-3864, JS-3866) remove that window where the header can be set.Fixes #24944
🤖 Generated with Claude Code