deno
deno copied to clipboard
Deno panic when customizing `Error.prepareStackTrace`
Version: Deno 2.3.3
Hi,
I would like to report a bug in Deno that causes panic. It can be reproduced by running the following code snippet. It worked on both Windows and MacOS.
class bar {
constructor() {
Error.prepareStackTrace = function (error, stack) {
stack[0].getFileName();
stack[1].getFileName();
stack[2].getFileName();
};
this.stack = new Error("bar").stack;
}
}
function foo() {
throw new bar(() => message);
}
Object.defineProperty(Array.prototype, "0", {
get: foo,
set: foo,
});
x; //node and bun throws Reference Error: x is not defined
Adding the relevant panic:
file:///prooject/bar.mjs:161: Uncaught TypeError: Cannot read properties of undefined (reading 'getFileName')
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.
Platform: macos aarch64
Version: 2.3.3
Args: ["deno", "bar.mjs"]
View stack trace at:
https://panic.deno.com/v2.3.3/aarch64-apple-darwin/4wyhKwkosqBgxi5qBwqi5qBwmv5qBo9-7Lgyp8Lw8_9Lwvl3P
thread 'main' panicked at /Users/admin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/deno_core-0.347.0/error.rs:1260:55:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Stack trace:
-
trace -
deno::setup_panic_hook::{{closure}} -
std::panicking::rust_panic_with_hook -
std::panicking::begin_panic_handler::{{closure}} -
std::panicking::begin_panic_handler::{{closure}} -
std::os::fd::owned::BorrowedFd::borrow_raw -
<std::os::fd::owned::OwnedFd as std::os::fd::owned::AsFd>::as_fd -
<std::sys::pal::unix::fd::FileDesc as std::os::fd::owned::AsFd>::as_fd -
core::fmt::Formatter::pad_integral -
core::panicking::assert_failed -
core::option::expect_failed -
<unsafe extern "C" fn(A0) .> R as v8::support::CFnFrom<F>>::mapping::c_fn
View trace: here
I will work on this!