From dfbb22a1acda119d55166d5c6b8c684227d03f8f Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Thu, 14 Nov 2024 08:22:16 -0700 Subject: [PATCH] fix: catch exceptions setting Error.stackTraceLimit 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 --- lib/cli/cli.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cli/cli.js b/lib/cli/cli.js index b1b5354081..5a4c6b8d53 100755 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -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);