test(node): Fix flaky ANR tests by waiting for debugger to be ready#21011
Merged
Conversation
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>
nicohrubec
approved these changes
May 19, 2026
Member
|
did you verify that you could actually reproduce the flakiness locally without this change? |
Member
Author
Yes it failed sometimes locally without the fix. I ran 1000 tests after each other to verify that. My laptop is close to fried |
Member
|
lol lgtm then |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
waitForDebuggerReadyhelper to the test utils that pollsinspector.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.