-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test(tanstackstart-react): Move initialization to client entry point #21161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nicohrubec
merged 4 commits into
develop
from
test/tanstack-start-early-init-reproductions
May 26, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2be523a
test(tanstackstart-react): Add failing E2E tests for early client init
nicohrubec c9e28b6
fix(tanstackstart-react): Move Sentry.init() to client entry point
nicohrubec 7ca834c
docs: Add changelog entry for early client init
nicohrubec e1f999b
ci: retrigger
nicohrubec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
27 changes: 27 additions & 0 deletions
27
dev-packages/e2e-tests/test-applications/tanstackstart-react-cloudflare/src/client.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import * as Sentry from '@sentry/browser'; | ||
| import { StartClient } from '@tanstack/react-start/client'; | ||
| import { StrictMode, startTransition } from 'react'; | ||
| import { hydrateRoot } from 'react-dom/client'; | ||
|
|
||
| Sentry.init({ | ||
| environment: 'qa', | ||
| dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
| tracesSampleRate: 1.0, | ||
| release: 'e2e-test', | ||
| tunnel: 'http://localhost:3031/', | ||
| }); | ||
|
|
||
| console.log('early-breadcrumb-from-client-entry'); | ||
|
|
||
| if (window.location.pathname === '/crash-before-hydration') { | ||
| throw new Error('Client Entry Crash'); | ||
| } | ||
|
|
||
| startTransition(() => { | ||
| hydrateRoot( | ||
| document, | ||
| <StrictMode> | ||
| <StartClient /> | ||
| </StrictMode>, | ||
| ); | ||
| }); |
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
13 changes: 13 additions & 0 deletions
13
...ts/test-applications/tanstackstart-react-cloudflare/src/routes/crash-before-hydration.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { createFileRoute } from '@tanstack/react-router'; | ||
|
|
||
| export const Route = createFileRoute('/crash-before-hydration')({ | ||
| component: CrashPage, | ||
| }); | ||
|
|
||
| function CrashPage() { | ||
| return ( | ||
| <div> | ||
| <p>This page crashes in client.tsx before hydration</p> | ||
| </div> | ||
| ); | ||
| } |
23 changes: 23 additions & 0 deletions
23
...kages/e2e-tests/test-applications/tanstackstart-react-cloudflare/tests/early-init.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { waitForError } from '@sentry-internal/test-utils'; | ||
|
|
||
| test('should capture errors thrown in client entry before hydration', async ({ page }) => { | ||
| const errorEventPromise = waitForError('tanstackstart-react-cloudflare', errorEvent => { | ||
| return errorEvent?.exception?.values?.[0]?.value === 'Client Entry Crash'; | ||
| }); | ||
|
|
||
| await page.goto('/crash-before-hydration'); | ||
|
|
||
| const errorEvent = await errorEventPromise; | ||
|
|
||
| expect(errorEvent.exception?.values?.[0]).toMatchObject({ | ||
| type: 'Error', | ||
| value: 'Client Entry Crash', | ||
| }); | ||
|
|
||
| const consoleBreadcrumbs = errorEvent.breadcrumbs?.filter( | ||
| b => b.category === 'console' && b.message?.includes('early-breadcrumb-from-client-entry'), | ||
| ); | ||
|
|
||
| expect(consoleBreadcrumbs?.length).toBeGreaterThanOrEqual(1); | ||
| }); |
29 changes: 29 additions & 0 deletions
29
dev-packages/e2e-tests/test-applications/tanstackstart-react/src/client.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import * as Sentry from '@sentry/tanstackstart-react'; | ||
| import { StartClient } from '@tanstack/react-start/client'; | ||
| import { StrictMode, startTransition } from 'react'; | ||
| import { hydrateRoot } from 'react-dom/client'; | ||
|
|
||
| Sentry.init({ | ||
| environment: 'qa', // dynamic sampling bias to keep transactions | ||
| dsn: __APP_DSN__, | ||
| // We recommend adjusting this value in production, or using tracesSampler | ||
| // for finer control | ||
| tracesSampleRate: 1.0, | ||
| release: 'e2e-test', | ||
| tunnel: __APP_TUNNEL__, | ||
| }); | ||
|
|
||
| console.log('early-breadcrumb-from-client-entry'); | ||
|
|
||
| if (window.location.pathname === '/crash-before-hydration') { | ||
| throw new Error('Client Entry Crash'); | ||
| } | ||
|
|
||
| startTransition(() => { | ||
| hydrateRoot( | ||
| document, | ||
| <StrictMode> | ||
| <StartClient /> | ||
| </StrictMode>, | ||
| ); | ||
| }); |
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
13 changes: 13 additions & 0 deletions
13
...ges/e2e-tests/test-applications/tanstackstart-react/src/routes/crash-before-hydration.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { createFileRoute } from '@tanstack/react-router'; | ||
|
|
||
| export const Route = createFileRoute('/crash-before-hydration')({ | ||
| component: CrashPage, | ||
| }); | ||
|
|
||
| function CrashPage() { | ||
| return ( | ||
| <div> | ||
| <p>This page crashes in client.tsx before hydration</p> | ||
| </div> | ||
| ); | ||
| } |
28 changes: 28 additions & 0 deletions
28
dev-packages/e2e-tests/test-applications/tanstackstart-react/tests/early-init.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { waitForError } from '@sentry-internal/test-utils'; | ||
|
|
||
| const usesManagedTunnelRoute = | ||
| (process.env.E2E_TEST_TUNNEL_ROUTE_MODE ?? 'off') !== 'off' || process.env.E2E_TEST_CUSTOM_TUNNEL_ROUTE === '1'; | ||
|
|
||
| test.skip(usesManagedTunnelRoute, 'Default e2e suites run only in the proxy variant'); | ||
|
|
||
| test('should capture errors thrown in client entry before hydration', async ({ page }) => { | ||
| const errorEventPromise = waitForError('tanstackstart-react', errorEvent => { | ||
| return errorEvent?.exception?.values?.[0]?.value === 'Client Entry Crash'; | ||
| }); | ||
|
|
||
| await page.goto('/crash-before-hydration'); | ||
|
|
||
| const errorEvent = await errorEventPromise; | ||
|
|
||
| expect(errorEvent.exception?.values?.[0]).toMatchObject({ | ||
| type: 'Error', | ||
| value: 'Client Entry Crash', | ||
| }); | ||
|
|
||
| const consoleBreadcrumbs = errorEvent.breadcrumbs?.filter( | ||
| b => b.category === 'console' && b.message?.includes('early-breadcrumb-from-client-entry'), | ||
| ); | ||
|
|
||
| expect(consoleBreadcrumbs?.length).toBeGreaterThanOrEqual(1); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.