Skip to content

test(browser): Stabilize flaky manual-mode profile_chunk test#22040

Merged
mydea merged 1 commit into
developfrom
fix/manual-profiling-largesum-sampling-flake
Jul 8, 2026
Merged

test(browser): Stabilize flaky manual-mode profile_chunk test#22040
mydea merged 1 commit into
developfrom
fix/manual-profiling-largesum-sampling-flake

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Stabilizes the flaky browser integration test [chromium] › suites/profiling/manualMode/test.ts › sends profile_chunk envelopes in manual mode.

Root cause

Two manual-mode-specific timing races against the 10ms JS self-profiler sample interval:

  1. largeSum can be missed by sampling. In manual mode, the first profile_chunk must contain both fibonacci and largeSum (the assertion uses arrayContaining, so all expected names must be present). largeSum() ran only 1_000_000 iterations, which can complete inside a single ~10ms profiler tick — occasionally no sample lands on it, so largeSum is absent from the chunk's frames and the assertion fails. The sibling traceLifecycleMode_overlapping-spans/subject.js already documented and fixed this exact failure mode by bumping the same loop to 2_500_000 iterations.

  2. The second chunk can arrive after the envelope wait times out. The second profile_chunk is only emitted after three heavy fibonacci(40)-class computations run synchronously (fibonacci + notProfiledFib + fibonacci2). Under CI load these can push the second chunk's request past the 8000ms wait, leaving only one chunk captured and failing expect(profileChunkEnvelopes.length).toBe(2).

Fix

  • Bump largeSum() to 2_500_000 iterations so it stays on-stack across several profiler ticks, mirroring traceLifecycleMode_overlapping-spans.
  • Raise the profile_chunk envelope wait from 8000ms to 15_000ms, matching the timeout the same sibling already uses for comparably heavy profiling work.

Neither change loosens any assertion — the test still requires exactly two chunks and the same function names; it just gives the profiler a reliable window to sample and enough time to emit both chunks.

Fixes #22033

Fixes #22033

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot requested a review from a team as a code owner July 8, 2026 07:44
@github-actions github-actions Bot requested review from Lms24, logaretm and mydea and removed request for a team July 8, 2026 07:44
@mydea mydea enabled auto-merge (squash) July 8, 2026 07:46
@mydea mydea merged commit 73e56ff into develop Jul 8, 2026
72 checks passed
@mydea mydea deleted the fix/manual-profiling-largesum-sampling-flake branch July 8, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant