馃悰 Prevent duplicate Next.js RUM views from discarded renders - #4940
Open
BeltranBulbarellaDD wants to merge 1 commit into
Open
馃悰 Prevent duplicate Next.js RUM views from discarded renders#4940BeltranBulbarellaDD wants to merge 1 commit into
BeltranBulbarellaDD wants to merge 1 commit into
Conversation
|
BeltranBulbarellaDD
marked this pull request as ready for review
August 19, 2026 15:16
lierniel
reviewed
Aug 19, 2026
Comment on lines
+7
to
+11
| useLayoutEffect(() => { | ||
| if (path !== null && previousPath.current !== path) { | ||
| previousPath.current = path | ||
| startNextjsView(viewName) | ||
| } |
Contributor
There was a problem hiding this comment.
Question:
Why not just useEffect() ? We're blocking the render by using useLayoutEffect(), which is not that I would expect from a monitoring tool
Contributor
Author
There was a problem hiding this comment.
The thing is that useLayoutEffect runs before paint and just by doing this fix we are going to be starting views later that what we would like to. useEffect would be just too late to start a view.
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.
Motivation
Fixes #4931, where
DatadogAppRouterandDatadogPagesRoutercould callstartNextjsView()during a render that React later discarded. Because the render-phaseuseRefguard is recreated for discarded fibers, those calls could create duplicate RUM views.Changes
useStartNextjsView, which callsstartNextjsView()fromuseLayoutEffectafter the render commits.Test instructions
should not create a view for a discarded App Router render.Checklist