Skip to content

Commit

Permalink
fix: catch exceptions setting Error.stackTraceLimit (#5254)
Browse files Browse the repository at this point in the history
When node is run with [--frozen-intrinsics], a `TypeError` is thrown
when any intrinsic objects or their properties are modified.  This
occurs when attempting to set `Error.stackTraceLimit`.  To avoid exiting
due to an uncaught exception, catch the exception, debug log it, and
continue.

[--frozen-intrinsics]: https://nodejs.org/api/cli.html#--frozen-intrinsics

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
  • Loading branch information
kevinoid authored Dec 9, 2024
1 parent 210d658 commit 259f8f8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => {
module.paths.push(cwd(), path.resolve('node_modules'));
}

Error.stackTraceLimit = Infinity; // configurable via --stack-trace-limit?
try {
Error.stackTraceLimit = Infinity; // configurable via --stack-trace-limit?
} catch (err) {
debug('unable to set Error.stackTraceLimit = Infinity', err);
}

var args = mochaArgs || loadOptions(argv);

Expand Down

0 comments on commit 259f8f8

Please sign in to comment.