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
@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 (19b861d).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61615      +/-   ##
==========================================
- Coverage   89.76%   89.74%   -0.03%     
==========================================
  Files         673      674       +1     
  Lines      203945   204193     +248     
  Branches    39191    39266      +75     
==========================================
+ Hits       183076   183257     +181     
- Misses      13198    13244      +46     
- Partials     7671     7692      +21     

see 41 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

@nodejs-github-bot
Copy link
Collaborator

@mcollina mcollina added commit-queue Add this label to land a pull request using GitHub Actions. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed needs-ci PRs that need a full CI run. labels Feb 2, 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 db115c1 to 19b861d Compare February 2, 2026 12:10
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 2, 2026
@mcollina
Copy link
Member Author

mcollina commented Feb 2, 2026

@lpinca @MoLow I need another approval

@github-actions github-actions bot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Feb 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Failed to start CI
   ⚠  Commits were pushed since the last approving review:
   ⚠  - test: fix race condition in watch mode tests
   ✘  Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/21602719238

@MoLow MoLow added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. labels Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. request-ci Add this label to start a Jenkins CI on a PR. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants