denoland / import_map

An implementation of WICG Import Maps specification
MIT License
31 stars 15 forks source link

Panic upon invalid import involving an import map #43

Open hen-x opened 2 years ago

hen-x commented 2 years ago

Under Deno 1.23.3 and 1.24.0, it is possible to produce a panic when running deno check given a particular invalid import configuration.

See a minimal repro here.

Panic trace:

============================================================
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.24.0
Args: ["/Users/henx/.deno/bin/deno", "check", "repro.ts"]

thread 'main' panicked at 'assertion failed: resolution_result.to_string().ends_with(\'/\')', /Users/ib/.cargo/registry/src/github.com-1ecc6299db9ec823/import_map-0.12.1/src/lib.rs:942:5
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: import_map::resolve_imports_match
   4: import_map::ImportMap::resolve
   5: <deno::resolver::ImportMapResolver as deno_graph::source::Resolver>::resolve
   6: deno_graph::graph::resolve
   7: deno_graph::graph::parse_module_from_ast
   8: deno_graph::graph::parse_module
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  10: deno::proc_state::ProcState::prepare_module_load::{{closure}}
  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  14: deno::main::{{closure}}
  15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  16: deno_runtime::tokio_util::run_local
  17: deno::main
kitsonk commented 2 years ago

We should either return a diagnostic earlier or error or return an empty value instead of panicking.