Skip to content

fix: require serializer.mjs in parallel worker pool files - #6055

Merged
JoshuaKGoldberg merged 1 commit into
mochajs:mainfrom
GrahamCampbell:fix/parallel-serializer-require
Jun 10, 2026
Merged

JoshuaKGoldberg merged 1 commit into
mochajs:mainfrom
GrahamCampbell:fix/parallel-serializer-require

Conversation

@GrahamCampbell

@GrahamCampbell GrahamCampbell commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

#6011 renamed lib/nodejs/serializer.js to serializer.mjs and updated one of its three consumers (lib/nodejs/worker.js), but the other two still require the module without an extension. CommonJS resolution never tries .mjs, so both requires fail unconditionally, and as of 12.0.0-beta-9.5 any --parallel run crashes at startup with Cannot find module './serializer' (see #6054 for a minimal reproduction).

This PR updates the three remaining stale requires to reference ./serializer.mjs explicitly, mirroring what worker.js already does:

  • lib/nodejs/buffered-worker-pool.js — loaded in the main process via Mocha.parallelMode(); this is the startup crash.
  • lib/nodejs/reporters/parallel-buffered.js — loaded in the worker processes; masked by the first failure until that one is fixed.
  • test/node-unit/serializer.spec.js — the serializer spec itself cannot currently load on main for the same reason (its sibling worker.spec.js was already updated in chore: convert lib/nodejs/ utility files to ESM #6011).

require() of a synchronous ESM graph is supported at Mocha's engines floor (^20.19.0 || >=22.12.0), so no loader changes are needed. Verified by applying the two lib/ changes to the published 12.0.0-beta-9.5 package: --parallel goes from the startup crash to passing, and serial runs are unaffected.

No new test is added: the fix makes the existing serializer spec loadable again, and any parallel-mode integration test exercises the repaired path by construction. #5969 (converting the worker-pool files themselves to ESM) will subsume these requires eventually; this is the minimal interim fix so the next beta doesn't ship with parallel mode unusable.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: GrahamCampbell / name: Graham Campbell (78584fd)

@github-actions

This comment has been minimized.

@codecov

codecov Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.12%. Comparing base (8df3ba6) to head (78584fd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6055      +/-   ##
==========================================
+ Coverage   78.08%   78.12%   +0.04%     
==========================================
  Files          63       63              
  Lines        4590     4590              
  Branches      977      977              
==========================================
+ Hits         3584     3586       +2     
+ Misses       1006     1004       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@GrahamCampbell

Copy link
Copy Markdown
Contributor Author

The failing test is an existing flaky issue. I've prepared PRs to fix this:

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix!

@JoshuaKGoldberg
JoshuaKGoldberg merged commit ffdf37c into mochajs:main Jun 10, 2026
153 of 156 checks passed
@GrahamCampbell
GrahamCampbell deleted the fix/parallel-serializer-require branch June 10, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug: parallel mode crashes at startup with Cannot find module './serializer' in 12.0.0-beta-9.5

2 participants