Skip to content

test(browser): Fix flaky replay and tracing integration tests - #26478

Merged
s1gr1d merged 2 commits into
developfrom
sig/test-browser-flaky-waits
Nov 17, 2026
Merged

s1gr1d merged 2 commits into
developfrom
sig/test-browser-flaky-waits

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Nov 17, 2026

Copy link
Copy Markdown
Member

What

Seven browser integration tests no longer depend on timing that the test does not control:

  • replay/canvas/records and replay/multiple-pages wait for the segment that holds the data, not for a fixed segment id.
  • reportPageLoaded/finalTimeout (both variants) measures from Sentry.init().
  • long-animation-frame-enabled (both variants) puts mousedown and click into different frames.
  • navigation-navigation-keypress waits for the redirect URL, not for 500 ms.
  • dsc-txn-name-update routes the https:// URL that the page fetches.
  • fetch-track-stream-performance accepts a stream span of 0 ms.

Why

Each of these tests failed in CI in the last month without a defect in the SDK. Examples:

  • The canvas snapshot can land in the segment of the click. Segment 2 then never exists, and the test timed out (7 PR runs).
  • After a link click, the old page can start a flush before it unloads. That flush uses up a segment id, so the new page sends id 5 and the test waited for id 4 (6 runs).
  • The final timeout starts at Sentry.init(), but the span starts at the time origin. A page load slower than 500 ms broke the < 3.5 bound (5 runs).
  • dsc-txn-name-update sent its requests to real DNS, because the route pattern was http://.

Two assertions are wider than before, on purpose:

  • replay/multiple-pages accepts one of two segment ids after a page change, because replay.ts increments the id before the send. The ids inside a page are still exact.
  • fetch-track-stream-performance uses >=. Playwright fulfills the route with a complete body, so a duration of 0 ms is correct there.

Checked locally on Chromium and WebKit with 3 repeats. The finalTimeout tests fail with a 2 s or 4 s timeout, and the canvas test fails when the canvas is not drawn.

Ref #26477

`replay/canvas/records` expected the canvas snapshot in segment 2. The snapshot can land in
the segment of the click, and then segment 2 never exists. The test now collects segments
until the snapshot arrives.

`replay/multiple-pages` expected a fixed segment id after a page change. The old page can use
up one id for a flush that it starts before it unloads. The test now waits for the first
segment of the new page and counts the later ids from it.
- `reportPageLoaded/finalTimeout`: the final timeout starts at `Sentry.init()`, but the test
  measured from the time origin, so a slow page load broke the upper bound.
- `long-animation-frame-enabled`: mousedown and click could share one long animation frame,
  which is then attributed to the wrong script.
- `navigation-navigation-keypress`: a fixed 500 ms wait raced the redirect at 400 + 100 ms.
- `dsc-txn-name-update`: the route pattern was `http://` and the page fetched `https://`, so
  the requests went to real DNS.
- `fetch-track-stream-performance`: the body is complete when the headers arrive, so the
  stream span can end in the clock tick in which it starts.
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 1f490be (PR test merge using develop at 524bd26)

Against: 524bd26 (develop) · base run #66453

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.1 kB - -
@sentry/browser - with treeshaking flags 28.3 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.2 kB - -
@sentry/browser (incl. Tracing) 52.28 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.29 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.25 kB - -
@sentry/browser (incl. Tracing, Replay) 92.82 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.6 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.21 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.6 kB - -
@sentry/browser (incl. Feedback) 47.73 kB - -
@sentry/browser (incl. sendFeedback) 30.69 kB - -
@sentry/browser (incl. FeedbackAsync) 35.69 kB - -
@sentry/browser (incl. Metrics) 31.43 kB - -
@sentry/browser (incl. Logs) 31.71 kB - -
@sentry/browser (incl. Metrics & Logs) 32.37 kB - -
@sentry/react 32.11 kB - -
@sentry/react (incl. Tracing) 54.95 kB - -
@sentry/vue 38.29 kB - -
@sentry/vue (incl. Tracing) 55.24 kB - -
@sentry/svelte 30.12 kB - -
@sentry/remix (Remix 3 client bundle) 58.06 kB - -
CDN Bundle 31.87 kB - -
CDN Bundle (incl. Tracing) 52.7 kB - -
CDN Bundle (incl. Logs, Metrics) 34.67 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.26 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.7 kB - -
CDN Bundle (incl. Tracing, Replay) 90.72 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.09 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.69 kB - -
CDN Bundle - uncompressed 92.98 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.45 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.33 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.08 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 231.44 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.61 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 283.24 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.02 kB - -
@sentry/nextjs (client) 58.57 kB - -
@sentry/sveltekit (client) 53.57 kB - -
@sentry/core/server 44.8 kB - -
@sentry/core/browser 14.4 kB - -
@sentry/node 151.66 kB -0.01% -5 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.33 kB - -
@sentry/node - without tracing 88.59 kB -0.01% -5 B 🔽
@sentry/node - without channel injection 140.62 kB -0.01% -2 B 🔽
@sentry/aws-serverless 98.96 kB -0.01% -7 B 🔽
@sentry/cloudflare (withSentry) - minified 206.71 kB - -
@sentry/cloudflare (withSentry) 479.81 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 232.07 kB - -

View base workflow run

@s1gr1d
s1gr1d marked this pull request as ready for review November 17, 2026 13:37

@msonnb msonnb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice thanks!

@s1gr1d
s1gr1d merged commit 72add88 into develop Nov 17, 2026
97 checks passed
@s1gr1d
s1gr1d deleted the sig/test-browser-flaky-waits branch November 17, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants