fix(js): end browser trace roots at real activity, not idle-timeout padding#70
Merged
DriesH merged 1 commit intoJul 9, 2026
Conversation
…adding A childless pageload/navigation root closed at now() (start + idleTimeout), inflating its duration by the whole idle window (e.g. a 488ms pageload reported as 2488ms with idleTimeout=2000). Roots now trim to an injected end floor: pageload -> Navigation Timing loadEventEnd, navigation -> its own start; endNow() trims the same way unless a child is still in flight.
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.
Stacked on #69 — targets
research/tracing-framework-routers, so the diff here is just this fix.Summary
Browser
pageload/navigationroot spans were reporting durations inflated by the wholeidleTimeout. A childless root (nofetch/xhrchildren during its window) closed atnow()=start + idleTimeout, so a real ~488ms pageload showed as 2488ms withidleTimeout: 2000.Root cause
IdleRootControllertrims a root's end to the last child's end on idle close, but fell back tonow()when there were no children (lastChildEndTime ?? now()), padding the duration by the full idle window.endNow()(route change /pagehide) had the samenow()behavior.Fix
Roots now trim to an injected end floor instead of
now():loadEventEnd(the browser's "page finished loading" mark; falls back todomContentLoadedEventEnd, thennow()).endNow()trims the same way, except when a child is still in flight — then it keepsnow()so in-progress work isn't cut short.Fetch-heavy roots are unchanged; they already trimmed to the last child.
Tests
IdleRootController: childless roots trim to the floor (notnow());endNowtrims unless a child is open.navigationTiming:computePageloadEndNano(loadEventEnd → domContentLoadedEventEnd → now fallbacks).@flareapp/jssuite green (154), typecheck + lint clean.Verified in the JS playground against a local Flare: the pageload that read 2488ms now reports its real ~488ms.