Skip to content

Conversation

@logaretm
Copy link
Collaborator

@logaretm logaretm commented Dec 10, 2025

Bad condition which short circuits the web vitals from being reported, I included a test anyways even though it doesn't reproduce it.

closes #18425

Closes #18464 (added automatically)???

Copilot AI review requested due to automatic review settings December 10, 2025 13:43
@linear
Copy link

linear bot commented Dec 10, 2025

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a logic error in the TanStack Router integration that was preventing web vitals from being reported during pageload transactions. The original condition incorrectly handled the case when fromLocation is undefined during initial pageloads.

  • Fixed the condition in onBeforeNavigate hook to properly check for fromLocation existence before comparing states
  • Added a test to verify pageload transactions include web vitals measurements (ttfb, lcp, fp, fcp)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/react/src/tanstackrouter.ts Fixed the logic to explicitly check for fromLocation existence before state comparison, preventing incorrect navigation span creation during pageloads
dev-packages/e2e-tests/test-applications/tanstack-router/tests/routing-instrumentation.test.ts Added test to verify that pageload transactions correctly include web vitals measurements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}),
}),
});
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test doesn't reproduce the regression being fixed (Bugbot Rules)

Per the review rules for fix PRs: the test should fail before the fix and pass after. The PR author explicitly states "I included a test anyways even though it doesn't reproduce it," meaning this test would have passed with the old buggy code. For proper regression testing, a test that specifically validates the condition where fromLocation is undefined during initial pageload and verifies no spurious navigation span is created would more directly test the fix.

Fix in Cursor Fix in Web

Copy link
Member

@nicohrubec nicohrubec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@logaretm logaretm merged commit 5affac5 into develop Dec 11, 2025
104 checks passed
@logaretm logaretm deleted the awad/js-1264-core-web-vitals-arent-reported-when-enabling-tanstack-router branch December 11, 2025 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants