Skip to content

test(node): Fix flaky ANR tests by waiting for debugger to be ready#21011

Merged
JPeer264 merged 1 commit into
developfrom
jp/fix-anr-flaky-tests
May 20, 2026
Merged

test(node): Fix flaky ANR tests by waiting for debugger to be ready#21011
JPeer264 merged 1 commit into
developfrom
jp/fix-anr-flaky-tests

Conversation

@JPeer264
Copy link
Copy Markdown
Member

closes #20704
closes JS-2372

closes #20959
closes JS-2524

The ANR worker thread creates an InspectorSession and connects to the main thread's debugger. Previously, tests would start blocking work immediately, but the debugger session might not be fully initialized yet, causing stack traces to capture the wrong location (processTimers instead of longWork).

This adds a waitForDebuggerReady helper to the test utils that polls inspector.url() to detect when the debugger is active, then waits 200ms for the async session setup to complete before starting the blocking work.

First the LLM suggested to increase the timeout, but I didn't think that was a good solution, given that CI good have worse when it's busy. I tested that locally a lot of times and tried to slow down the process, seemed stable so far.

The ANR worker thread creates an InspectorSession and connects to the
main thread's debugger. Previously, tests would start blocking work
immediately, but the debugger session might not be fully initialized yet,
causing stack traces to capture the wrong location (processTimers instead
of longWork).

This adds a waitForDebuggerReady helper to @sentry-internal/test-utils
that polls inspector.url() to detect when the debugger is active, then
waits 200ms for the async session setup to complete before starting the
blocking work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@JPeer264 JPeer264 requested a review from a team May 19, 2026 16:18
@JPeer264 JPeer264 self-assigned this May 19, 2026
@JPeer264 JPeer264 requested a review from a team as a code owner May 19, 2026 16:18
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 19, 2026

JS-2372

JS-2524

@nicohrubec
Copy link
Copy Markdown
Member

did you verify that you could actually reproduce the flakiness locally without this change?

@JPeer264
Copy link
Copy Markdown
Member Author

JPeer264 commented May 19, 2026

did you verify that you could actually reproduce the flakiness locally without this change?

Yes it failed sometimes locally without the fix. I ran 1000 tests after each other to verify that. My laptop is close to fried

@nicohrubec
Copy link
Copy Markdown
Member

lol lgtm then

@JPeer264 JPeer264 merged commit ba1a270 into develop May 20, 2026
231 checks passed
@JPeer264 JPeer264 deleted the jp/fix-anr-flaky-tests branch May 20, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants