denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
96.67k stars 5.34k forks source link

thread 'main' panicked at 'Custom error class must have a builder registered', core/error.rs:115:6 #16963

Open duart38 opened 1 year ago

duart38 commented 1 year ago

Hi, I seem to be running into the panic issue.

Platform: macos aarch64 Version: 1.28.3

thread 'main' panicked at 'Custom error class must have a builder registered', core/error.rs:115:6 stack backtrace: 0: 0x1054307bc - ::fmt::h2990a6f24ccff6db 1: 0x104bdcd7c - core::fmt::write::h91497fd291c8b104 2: 0x105406a24 - std::io::Write::write_fmt::h23fa41342cffacf4 3: 0x105434b94 - std::panicking::default_hook::{{closure}}::hb41cdb784f4c17ac 4: 0x105434858 - std::panicking::default_hook::hdfe992d5fb29a991 5: 0x104b26fe8 - deno::setup_panic_hook::{{closure}}::h5e935c84e6e3da4b 6: 0x1054350f0 - std::panicking::rust_panic_with_hook::h2eb0e4b718773521 7: 0x105434ed8 - std::panicking::begin_panic_handler::{{closure}}::h06a693206403b4d5 8: 0x105434e4c - std::sys_common::backtrace::__rust_end_short_backtrace::h8998defd518dbcad 9: 0x105434e28 - _rust_begin_unwind 10: 0x104bdaf0c - core::panicking::panic_fmt::ha46aa9af97eb193d 11: 0x104be0fac - core::panicking::panic_display::h0b3cf32cf3b35897 12: 0x104be0f70 - core::panicking::panic_str::hedee8590c93b39b0 13: 0x104be0f54 - core::option::expect_failed::h0b457b49698c9371 14: 0x104c70ae4 - deno_core::error::to_v8_error::h406ecfc9d61f68bb 15: 0x104f459ec - <extern "C" fn(A0) .> R as v8::support::CFnFrom>::mapping::c_fn::h1613deedc870ec81

Things I noticed / tried

I've gone through my code line by line to see which part seems to be triggering the issue in the hopes that it helps?:

// Commenting out the `${curr.id!}` here seems to fix the issue?
prev[`${curr.id!}`] = {
          ...
          // OR: setting history here to an empty array also solves the issue
          history: stationData.filter((sd) => sd.station_id === curr.id),
}

The code above is from a reduce which at the end contains an object in the shape I want but I've also tried it using a regular for-of loop with the same panic.

Maybe it's also worth noting that the function (static) which executes the aforementioned code is called from within a generator function which was imported dynamically (import() syntax).

I've also tried inlining the logic of the aforementioned static function within the generator function (as opposed to calling the static method). This returned the same error (changing the ${curr.id!} herein still fixes the panic).

I've also tried calling the static method from a simple file with no extra logic (and thus no dynamic imports) and that seems to work perfectly fine.

TLDR: removing either prev[`${curr.id!}`] or history: stationData.filter((sd) => sd.station_id === curr.id) stops the panics.

bartlomieju commented 1 year ago

Hey @duart38, do you run into this issue using deno binary, or are you embedding it yourself?

duart38 commented 1 year ago

Hey @duart38, do you run into this issue using deno binary, or are you embedding it yourself?

Hello @bartlomieju, I run this using the deno binary

bartlomieju commented 1 year ago

Thanks, it's gonna be a bit tricky to debug, is there any chance your code is available online so I could run it myself?

duart38 commented 1 year ago

Thanks, it's gonna be a bit tricky to debug, is there any chance your code is available online so I could run it myself?

Unfortunately no. The code is from a university project and they don't allow us to post it publicly until after grading šŸ˜ž

bartlomieju commented 1 year ago

Thanks, it's gonna be a bit tricky to debug, is there any chance your code is available online so I could run it myself?

Unfortunately no. The code is from a university project and they don't allow us to post it publicly until after grading šŸ˜ž

That's unfortunate, I will add some debug logging to the problematic place so we at least get some info what's failing.

duart38 commented 1 year ago

@bartlomieju Thank you, I appreciate it allot

bartlomieju commented 1 year ago

@duart38 the improves debug logging is now released, let me know if you get a chance to get more output for this issue.

duart38 commented 1 year ago

@duart38 the improves debug logging is now released, let me know if you get a chance to get more output for this issue.

My code has changed a bit since the last time. Nevertheless I'm currently getting the following error:

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: 1.29.1
Args: ["deno", "run", "--allow-all", "--import-map", "https://raw.githubusercontent.com/duart38/serverless-sockets/main/import_map.json", "https://raw.githubusercontent.com/duart38/serverless-sockets/main/src/mod.ts"]

thread 'main' panicked at 'Custom error class must have a builder registered: Uncaught RangeError: Maximum call stack size exceeded', core/error.rs:126:7
stack backtrace:
   0:        0x105adb2e4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2990a6f24ccff6db
   1:        0x10526d058 - core::fmt::write::h91497fd291c8b104
   2:        0x105ab16e8 - std::io::Write::write_fmt::h23fa41342cffacf4
   3:        0x105adf6bc - std::panicking::default_hook::{{closure}}::hb41cdb784f4c17ac
   4:        0x105adf380 - std::panicking::default_hook::hdfe992d5fb29a991
   5:        0x1051b78c8 - deno::setup_panic_hook::{{closure}}::h1eb8b43e0442d230
   6:        0x105adfc18 - std::panicking::rust_panic_with_hook::h2eb0e4b718773521
   7:        0x105adfa00 - std::panicking::begin_panic_handler::{{closure}}::h06a693206403b4d5
   8:        0x105adf974 - std::sys_common::backtrace::__rust_end_short_backtrace::h8998defd518dbcad
   9:        0x105adf950 - _rust_begin_unwind
  10:        0x10526b1e8 - core::panicking::panic_fmt::ha46aa9af97eb193d
  11:        0x105301b98 - core::panicking::panic_display::hdd962ce9a6d1caaa
  12:        0x105300e80 - deno_core::error::to_v8_error::h1a5bf69112d26e65
  13:        0x1055faedc - <extern "C" fn(A0) .> R as v8::support::CFnFrom<F>>::mapping::c_fn::h2ed181fb4600f809