-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
status: accepting prsMocha can use your help with this one!Mocha can use your help with this one!type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Description
Bug Report Checklist
- I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- I have searched for related issues and issues with the
faq
label, but none matched my issue. - I have 'smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, my usage of Mocha, or Mocha itself.
- I want to provide a PR to resolve this
Expected
Test should report uncaught error (even with circular dependency) as failure and stop execution.
Actual
Test runs in infinite loop until configured timeout.
Minimal, Reproducible Example
describe("Test", () => {
it("throw circular dependency error object", async () => {
const errorA = {};
const objectB = {toA: errorA};
errorA.toB = objectB;
const d = new Error();
d.error = errorA;
throw d;
});
});
- Run
npx mocha
not in parallel mode, output is correct:
Test
1) throw circular dependency error object
0 passing (7ms)
1 failing
1) Test
throw circular dependency error object:
Error
at Context.<anonymous> (test\asset-design-service.test.js:7:15)
at processImmediate (node:internal/timers:483:21)
- Run
npx mocha --parallel
, infinite loop happens (nothing in console)
Versions
mocha: 10.7.3
node: v20.16.0
Additional Info
Issue is introduced in this commit: d7013dd which changed the passed object to breakCircularDeps
Using v10.7.0, the uncaught error is reported correctly in parallel mode:
Test
1) throw circular dependency error object
0 passing (858ms)
1 failing
1) Test
throw circular dependency error object:
Error
at Context.<anonymous> (test\asset-design-service.test.js:7:15)
at processImmediate (node:internal/timers:483:21)
In my actual project, this pairs
array grows infinitely as a result of the circular dependency:
Metadata
Metadata
Assignees
Labels
status: accepting prsMocha can use your help with this one!Mocha can use your help with this one!type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer