From d5a331e73882c7e1c1f6a4b53e352aafa3965b2b Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 8 Jul 2026 10:28:55 +0200 Subject: [PATCH] test(e2e): De-flake remix-hydrogen client tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two changes to reduce flakiness in the remix-hydrogen E2E client tests (CI runs these with retries: 0, so any transient failure is reported as flaky): - Drop `replayIntegration` (and `debug`) from the client SDK init. Replay was recorded intermittently (`replaysSessionSampleRate: 0.1`, and always on the error tests via `replaysOnErrorSampleRate: 1.0`), spinning up the replay worker and sending extra envelopes through the same tunnel — intermittent, timing- sensitive load that no test here asserts on. This matches the leaner hydrogen-react-router-7 sibling app. - Gate the "client-side exception" test on hydration by awaiting the pageload transaction before clicking the button, mirroring the existing mitigation in the navigation test. A click that lands before the onClick handler is attached never captures the exception. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../remix-hydrogen/app/entry.client.tsx | 7 ------- .../remix-hydrogen/tests/client-errors.test.ts | 11 ++++++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/remix-hydrogen/app/entry.client.tsx b/dev-packages/e2e-tests/test-applications/remix-hydrogen/app/entry.client.tsx index 82d9ae571fe1..6b9287e6f709 100644 --- a/dev-packages/e2e-tests/test-applications/remix-hydrogen/app/entry.client.tsx +++ b/dev-packages/e2e-tests/test-applications/remix-hydrogen/app/entry.client.tsx @@ -8,22 +8,15 @@ Sentry.init({ environment: 'qa', // dynamic sampling bias to keep transactions // Could not find a working way to set the DSN in the browser side from the environment variables dsn: 'https://public@dsn.ingest.sentry.io/1337', - debug: true, integrations: [ Sentry.browserTracingIntegration({ useEffect, useLocation, useMatches, }), - Sentry.replayIntegration({ - maskAllText: true, - blockAllMedia: true, - }), ], tracesSampleRate: 1.0, - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, tunnel: 'http://localhost:3031/', // proxy server }); diff --git a/dev-packages/e2e-tests/test-applications/remix-hydrogen/tests/client-errors.test.ts b/dev-packages/e2e-tests/test-applications/remix-hydrogen/tests/client-errors.test.ts index 747ce8677afb..531bfd82f3f0 100644 --- a/dev-packages/e2e-tests/test-applications/remix-hydrogen/tests/client-errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/remix-hydrogen/tests/client-errors.test.ts @@ -1,13 +1,22 @@ import { expect, test } from '@playwright/test'; -import { waitForError } from '@sentry-internal/test-utils'; +import { waitForError, waitForTransaction } from '@sentry-internal/test-utils'; test('Sends a client-side exception to Sentry', async ({ page }) => { + // The pageload transaction only completes once the client SDK and Remix have hydrated. + // Awaiting it before clicking guarantees the button's onClick handler is attached — a click + // that lands before hydration would do nothing, and the exception would never be captured. + const pageloadTransactionPromise = waitForTransaction('remix-hydrogen', transactionEvent => { + return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/'; + }); + const errorPromise = waitForError('remix-hydrogen', errorEvent => { return errorEvent.exception?.values?.[0].value === 'I am an error!'; }); await page.goto('/'); + await pageloadTransactionPromise; + const exceptionButton = page.locator('id=exception-button'); await exceptionButton.click();