-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: core
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform
, babel.parse
)
Input code
import { parse } from "@babel/core";
console.log(parse("").type);
Configuration file name
No response
Configuration
No response
Current and expected behavior
$ node reproduce.mjs
File
$ node --frozen-intrinsics reproduce.mjs
(node:602173) ExperimentalWarning: The --frozen-intrinsics flag is experimental
(Use `node --trace-warnings ...` to show where the warning was created)
/path/to/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:65
Error.stackTraceLimit && (Error.stackTraceLimit = Math.max(Error.stackTraceLimit, MIN_STACK_TRACE_LIMIT));
^
TypeError <Object <Object <[Object: null prototype] {}>>>: Cannot assign to read only property 'stackTraceLimit' of function 'function Error() { [native code] }'
at setupPrepareStackTrace (/path/to/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:65:51)
at stopHiding - secret - don't use this - v1 (/path/to/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:45:5)
at parse (/path/to/node_modules/@babel/core/lib/parse.js:34:76)
at file:///path/to/reproduce.mjs:2:13
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Node.js v18.15.0
Environment
"@babel/core": "^7.21.8"
node v18.15.0
Possible solution
diff --git a/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js b/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js
index 9b6ce01..0757ad6 100644
--- a/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js
+++ b/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js
@@ -62,6 +62,7 @@ function setupPrepareStackTrace() {
prepareStackTrace = defaultPrepareStackTrace
} = Error;
const MIN_STACK_TRACE_LIMIT = 50;
+ try {
Error.stackTraceLimit && (Error.stackTraceLimit = Math.max(Error.stackTraceLimit, MIN_STACK_TRACE_LIMIT));
Error.prepareStackTrace = function stackTraceRewriter(err, trace) {
let newTrace = [];
@@ -87,6 +88,7 @@ function setupPrepareStackTrace() {
}
return prepareStackTrace(err, newTrace);
};
+ } catch {}
}
function defaultPrepareStackTrace(err, trace) {
if (trace.length === 0) return ErrorToString(err);
$ node --frozen-intrinsics reproduce.mjs
(node:604212) ExperimentalWarning: The --frozen-intrinsics flag is experimental
(Use `node --trace-warnings ...` to show where the warning was created)
File
Additional context
No response
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: core