Skip to content

Commit b503ac9

Browse files
committed
fixup! fix(react): Match TanStack Router pageload against the router location
1 parent 5cf5393 commit b503ac9

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

dev-packages/e2e-tests/test-applications/tanstack-router/tests/basepath.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@ test.describe('router basepath', () => {
3131
expect(traceData).toHaveProperty(['url.template'], '/posts/$postId');
3232
});
3333

34-
// The scope transaction is set when the pageload span starts, and the later `updateName` in
35-
// `onResolved` does not rewrite it — so a wrong initial match mislabelled every error for the
36-
// whole page lifetime. This is the part of the bug the transaction name alone does not reveal.
34+
// The first test only checks the span. The scope transaction is a separate value: it is set once
35+
// when the pageload span starts, and the later `updateName` in `onResolved` does not rewrite it.
36+
// So even when the sent transaction name is correct, errors captured after the pageload still
37+
// carry the name from the initial match. This test checks that scope transaction.
3738
test('attributes errors to the matched route for the whole page lifetime', async ({ page }) => {
39+
const transactionPromise = waitForTransaction('tanstack-router', async transactionEvent => {
40+
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
41+
});
3842
const errorPromise = waitForError('tanstack-router', async errorEvent => {
3943
return errorEvent.exception?.values?.[0]?.value === 'Error thrown after pageload';
4044
});
4145

4246
await page.goto(`${BASE}/posts/456`);
47+
await transactionPromise;
4348

44-
await page.waitForTimeout(1000);
4549
await page.evaluate(() => {
4650
setTimeout(() => {
4751
throw new Error('Error thrown after pageload');

0 commit comments

Comments
 (0)