Skip to content

test(node): Fix flaky thread-blocked-native worker thread test#21026

Merged
JPeer264 merged 1 commit into
developfrom
jp/fix-thread-blocked-native-flaky
May 20, 2026
Merged

test(node): Fix flaky thread-blocked-native worker thread test#21026
JPeer264 merged 1 commit into
developfrom
jp/fix-thread-blocked-native-flaky

Conversation

@JPeer264
Copy link
Copy Markdown
Member

closes #20703
closes JS-2371

closes #20676
closes JS-2358

This was the best guess from Claude. I tried to reproduce this locally but failed. I used Docker to change the resources and lowered the CPU and memory on a reproduction. But I never reproduced the same failing state. However, this new approach is faster (Claude was very proud of that) as it is not waiting 10s, before it starts, but starts as soon as everything is set up - that also never failed locally - so it is a shot in the dark 🤞


Claude message:

The worker thread test was flaky on CI because it used a fixed 10s delay before blocking the event loop. On slow CI machines, the Sentry SDK polling might not have fully started within that time window.

Replace the fixed delay with active polling that waits for the ThreadBlocked integration to be installed, then waits 1s for polling to start before blocking.

This makes the test:

  • More reliable: actively verifies Sentry is ready instead of hoping
  • Faster: ~3s vs ~12s locally
  • Has a 30s timeout as a safety net

The worker thread test was flaky on CI because it used a fixed 10s delay
before blocking the event loop. On slow CI machines, the Sentry SDK
polling might not have fully started within that time window.

Replace the fixed delay with active polling that waits for the
ThreadBlocked integration to be installed, then waits 1s for polling
to start before blocking.

This makes the test:
- More reliable: actively verifies Sentry is ready instead of hoping
- Faster: ~3s vs ~12s locally
- Has a 30s timeout as a safety net

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

linear-code Bot commented May 20, 2026

JS-2371

JS-2358

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 00b79e1. Configure here.

waitForSentryReady().then(() => {
longWork();
}, 10_000);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Worker checks main-only client

Medium Severity

waitForSentryReady calls Sentry.getClient() inside the spawned worker, but Sentry is initialized via --import on the parent process only. Worker isolates typically have no client, so the ThreadBlocked check never succeeds and the loop always waits the full 30s timeout before longWork(), undermining the intended early-start fix.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 00b79e1. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So far it worked quite nicely

@JPeer264 JPeer264 merged commit 3d2b4d6 into develop May 20, 2026
49 checks passed
@JPeer264 JPeer264 deleted the jp/fix-thread-blocked-native-flaky branch May 20, 2026 08:13
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