Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread 'main' panicked at 'called Result::unwrap() on an Err value: ExpectedString', core/error.rs:202:52 #14518

Closed
NetOpWibby opened this issue May 6, 2022 · 2 comments · Fixed by #14529 or javascript-indonesias/deno#273

Comments

@NetOpWibby
Copy link

============================================================
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.21.0
Args: ["deno", "run", "--allow-net", "--allow-read", "--allow-run", "--allow-write", "main.ts"]

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ExpectedString', core/error.rs:202:52
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Initial backtrace

stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: deno_core::error::JsError::inner_from_v8_exception
   4: deno_core::runtime::exception_to_err_result
   5: deno_core::runtime::JsRuntime::check_promise_exceptions
   6: deno_core::runtime::JsRuntime::poll_event_loop
   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   9: deno::run_command::{{closure}}
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  11: deno::main::{{closure}}
  12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  13: deno_runtime::tokio_util::run_basic
  14: deno::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Full backtrace

stack backtrace:
   0:        0x1015314f4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd6a6e3b094c481b1
   1:        0x100e1e614 - core::fmt::write::h55deb439a2fa505d
   2:        0x10151c000 - std::io::Write::write_fmt::hdd0ccc220f7ec3f7
   3:        0x10152806c - std::panicking::default_hook::{{closure}}::haecbbf48cd1ad553
   4:        0x101527cec - std::panicking::default_hook::hdf33d6d87b6673e5
   5:        0x100cb741c - deno::setup_panic_hook::{{closure}}::hfdede1c1d271ae05
   6:        0x101528b58 - std::panicking::rust_panic_with_hook::ha19270fc750e5dcf
   7:        0x101531840 - std::panicking::begin_panic_handler::{{closure}}::h520977148193b087
   8:        0x1015317c0 - std::sys_common::backtrace::__rust_end_short_backtrace::h563c939a775416b3
   9:        0x1015284c4 - _rust_begin_unwind
  10:        0x100e222b8 - core::panicking::panic_fmt::h0908dd8514c30916
  11:        0x100e2a1bc - core::result::unwrap_failed::ha509accbcac71268
  12:        0x100ea56b4 - deno_core::error::JsError::inner_from_v8_exception::h2e88aa9f4d1c2f9d
  13:        0x100ee330c - deno_core::runtime::exception_to_err_result::hbe4add7992e624d1
  14:        0x100ee392c - deno_core::runtime::JsRuntime::check_promise_exceptions::hd9c6e1da42698d34
  15:        0x100edf854 - deno_core::runtime::JsRuntime::poll_event_loop::h25350bb0c322ac31
  16:        0x100d3a9b8 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hdfbb04abf6cc0ec8
  17:        0x100d05c08 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h54207a51ff039d8e
  18:        0x100cb2b28 - deno::run_command::{{closure}}::hda6f98d1a70307df
  19:        0x100cfcfc8 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h38759e15ec531747
  20:        0x100cba9d0 - deno::main::{{closure}}::h51898a97c1e85b1e
  21:        0x100d332f4 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hc3e42d1078066fe1
  22:        0x100bfb51c - deno_runtime::tokio_util::run_basic::h6d7feeb5d04db814
  23:        0x100cb75c4 - deno::main::h6a9df70c24fff5e9
  24:        0x100cbe928 - std::sys_common::backtrace::__rust_begin_short_backtrace::h4da7f0cf5a3c7fb5
  25:        0x100d590c0 - _main

Repro

I'm using abc, trying to get a fallback working for 404 pages. Here is the code in question:

const showNotFound: HandlerFunc = async() => {
  return await handlebars.render("index", {
    content: await handlebars.render("page/not-found", {}),
    description: "A blog about the DNS, Handshake, and the internet at large.",
    head: `<link rel="stylesheet" href="/not-found.css"/>`
  });
};

app.pre((next: HandlerFunc) => (context: Context) => {
  try {
    console.log("hey");
    console.log(context);
    return next(context);
  } catch(error) {
    console.error(">>> error");
    console.error(error);
  } finally {
    return showNotFound(context);
  }
});

I saw the code in this issue and obviously, it doesn't work (at least, not in the way I'm using it).

@bartlomieju
Copy link
Member

CC @nayeemrmn it seems to be a problem with JS error deserialization, though I can't spot what's exactly wrong

@nayeemrmn
Copy link
Collaborator

@AaronO Do you know when serde_v8::from_v8::<NativeJsError>() might fail? https://github.com/denoland/deno/blob/v1.21.0/core/error.rs#L202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants