1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-31 03:29:10 -05:00

fix(core): Handle prepareStackTrace() throws (#9211)

Fixes #9206
This commit is contained in:
Nayeem Rahman 2021-01-21 09:48:04 +00:00 committed by GitHub
parent 18ac7d40c8
commit bdb1ee6480
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View file

@ -0,0 +1,6 @@
Error.prepareStackTrace = () => {
console.trace();
throw new Error("foo");
};
new Error("bar").stack;

View file

@ -0,0 +1,2 @@
[WILDCARD]error: Uncaught Error: foo
[WILDCARD]

View file

@ -2685,6 +2685,12 @@ itest!(_081_location_relative_fetch_redirect {
http_server: true,
});
itest!(_082_prepare_stack_trace_throw {
args: "run 082_prepare_stack_trace_throw.js",
output: "082_prepare_stack_trace_throw.js.out",
exit_code: 1,
});
itest!(js_import_detect {
args: "run --quiet --reload js_import_detect.ts",
output: "js_import_detect.ts.out",

View file

@ -193,11 +193,9 @@ impl JsError {
// Access error.stack to ensure that prepareStackTrace() has been called.
// This should populate error.__callSiteEvals.
let stack = get_property(scope, exception, "stack");
let stack: Option<v8::Local<v8::String>> =
get_property(scope, exception, "stack")
.unwrap()
.try_into()
.ok();
stack.and_then(|s| s.try_into().ok());
let stack = stack.map(|s| s.to_rust_string_lossy(scope));
// Read an array of structured frames from error.__callSiteEvals.