Skip to content

feat(nextjs): Wait for the resumed part of a document before starting the pageload - #25142

Merged
s1gr1d merged 9 commits into
developfrom
chargome/feat/nextjs-deferred-pageload-start
Oct 20, 2026
Merged

s1gr1d merged 9 commits into
developfrom
chargome/feat/nextjs-deferred-pageload-start

Conversation

@chargome

@chargome chargome commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Builds on #25141.

When a document resumes a prerendered shell, its sentry-trace tag 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 cacheComponents enabled, if there is no tag, no Server-Timing trace and the document is still streaming, it waits for the tag before creating the pageload span. Other apps keep the immediate start: without cacheComponents a tag is either in <head> from the start or never comes, so waiting only held the pageload back. The wait ends at DOMContentLoaded or 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-Timing follow-ups (JS-3864, JS-3866) remove that window where the header can be set.

figure-ppr

Fixes #24944

🤖 Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client decision rule for trace meta tags under cacheComponents

2 participants