Skip to content

🐛 Bug: Setting readOnly properties in breakCircularDeps breaks the reporter in parallel mode with allow-uncaught #5188

@satyen95

Description

@satyen95

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

Tests should run perfectly even if a it block (test) is failing
Error in it block (test) should not break parallel-buffered-runner.js even if --allow-uncaught is passed

Actual

All the tests get executed in the expected behaviour, but before the EVENT_RUN_END the process fails while serializing the results with the below error:

/XXX/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js:357
          throw err;
          
TypeError: Cannot set property maxHeaderSize of #<Object> which has only a getter
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:16)
    at _breakCircularDeps (/XXXnode_modules/mocha/lib/utils.js:679:18)
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:18)
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:18)
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:18)
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:18)
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:18)
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:18)
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:18)
    at _breakCircularDeps (/XXX/node_modules/mocha/lib/utils.js:679:18)

Failure point:
Screenshot 2024-08-06 at 3 43 31 PM
Reason: Trying to set a read-only property, which only has a getter

Minimal, Reproducible Example

Config:

  • allow-uncaught: true
  • parallel: true

Library dependency (easy to reproduce):
axios: 1.6.8

Create a suite, create a test in it, and make an incorrect/failing API call

Run the tests it will break

Versions

Mocha version: 10.7.0
Node: v20.15.1
OS: MacOS Sonoma 14.2.1 (23C71)

Additional Info

No response

Metadata

Metadata

Labels

status: accepting prsMocha can use your help with this one!type: buga defect, confirmed by a maintainer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions