Skip to content

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Feb 1, 2026

Summary

Fixes race condition in watch mode tests that caused intermittent failures.

Problem

The watch mode tests using runInBackground() had a race condition where the stdout "Failed running" message could arrive before stderr was fully collected, causing assertions on stderr content to fail with empty strings.

Solution

When "Failed running" is detected in stdout and stderr is empty, wait for the stderr 'data' event before resolving the promise. This is an event-driven approach rather than timing-based.

Verification

  • test-watch-mode-restart-esm-loading-error.mjs: 200 runs, 0 failures
  • test-watch-mode.mjs: 50 runs, 0 failures

Refs: nodejs/reliability#1450

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Feb 1, 2026
The watch mode tests using runInBackground() had a race condition where
stdout "Failed running" message could arrive before stderr was fully
collected, causing assertions on stderr content to fail with empty
strings.

Fix by waiting for stderr 'data' event if stderr is empty when "Failed
running" is detected. This is an event-driven approach rather than
timing-based.

Refs: nodejs/reliability#1450
@mcollina mcollina force-pushed the fix-flaky-test-watch-mode-restart-esm-loading-error branch from b6243b5 to db115c1 Compare February 1, 2026 16:11
@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.74%. Comparing base (27a7bbc) to head (db115c1).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61615      +/-   ##
==========================================
- Coverage   89.76%   89.74%   -0.03%     
==========================================
  Files         673      673              
  Lines      203945   203945              
  Branches    39191    39189       -2     
==========================================
- Hits       183076   183030      -46     
- Misses      13198    13237      +39     
- Partials     7671     7678       +7     

see 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 1, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 1, 2026
@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants