denoland / deno

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

Deno LSP crashes in VS Code with specific import map #17660

Closed watzon closed 1 year ago

watzon commented 1 year ago

Managed to get this as small as I can. Essentially it seems as though having an import map with a specific import is causing the Deno LSP to crash in VS Code every time I launch it, giving the following backtrace:

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: linux x86_64
Version: 1.30.2
Args: ["/home/watzon/.asdf/installs/deno/1.30.2/bin/deno", "lsp"]

thread 'main' panicked at 'internal error: entered unreachable code', cli/lsp/documents.rs:1455:7
stack backtrace:
   0:     0x5621c452461a - std::backtrace_rs::backtrace::libunwind::trace::h34aec3ef6cd8ad7e
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x5621c452461a - std::backtrace_rs::backtrace::trace_unsynchronized::h8035d38698d0f7a8
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5621c452461a - std::sys_common::backtrace::_print_fmt::hff968f6695a1ba22
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x5621c452461a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7eea0efe77acf1ec
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5621c455124e - core::fmt::write::hc553f17407eb0b48
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/fmt/mod.rs:1208:17
   5:     0x5621c451b1a5 - std::io::Write::write_fmt::h62e5f01a089f48c0
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/io/mod.rs:1682:15
   6:     0x5621c45243e5 - std::sys_common::backtrace::_print::h52d116aff3db4cd1
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x5621c45243e5 - std::sys_common::backtrace::print::h9e7d2f98fb7af075
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x5621c45261df - std::panicking::default_hook::{{closure}}::hf74999dab2d0a95c
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:267:22
   9:     0x5621c4525f1b - std::panicking::default_hook::hc11ca7d10c44c42f
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:286:9
  10:     0x5621c48d8408 - deno::setup_panic_hook::{{closure}}::hb57f03fbbfa3d934
  11:     0x5621c452696d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha7dbb2d260f78172
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/alloc/src/boxed.rs:2032:9
  12:     0x5621c452696d - std::panicking::rust_panic_with_hook::hdb4da1ae79c845a5
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:692:13
  13:     0x5621c45266a2 - std::panicking::begin_panic_handler::{{closure}}::h02b5b35b126d5cf2
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:577:13
  14:     0x5621c4524acc - std::sys_common::backtrace::__rust_end_short_backtrace::h6c6853376cf416d1
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x5621c45263f2 - rust_begin_unwind
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
  16:     0x5621c454e4f3 - core::panicking::panic_fmt::hfd9e949092070b66
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
  17:     0x5621c454e5cd - core::panicking::panic::h341545107301821d
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:111:5
  18:     0x5621c47bcc7d - <deno::lsp::documents::analyze_module::UnreachableParser as deno_graph::ast::ModuleParser>::parse_module::h9af39a0cd8be453e
  19:     0x5621c4b77acb - <deno_graph::ast::CapturingModuleParser as deno_graph::ast::ModuleParser>::parse_module::h78df078539240f63
  20:     0x5621c4b78a25 - <deno_graph::ast::DefaultModuleAnalyzer as deno_graph::analyzer::ModuleAnalyzer>::analyze::h8b35da8854622ebe
  21:     0x5621c4b78ba0 - <deno_graph::ast::CapturingModuleAnalyzer as deno_graph::analyzer::ModuleAnalyzer>::analyze::h761c25399d7906f7
  22:     0x5621c4b7adc6 - deno_graph::graph::parse_module::h5513cfb955a615e6
  23:     0x5621c4b7feb4 - deno_graph::parse_module::hc7e28ada48bf9e58
  24:     0x5621c47bcb8d - deno::lsp::documents::analyze_module::h219d061216cb8707
  25:     0x5621c47bc999 - deno::lsp::documents::parse_and_analyze_module::h1667bca1a5c336e3
  26:     0x5621c47b8f94 - deno::lsp::documents::Document::new::h4d668776518eae75
  27:     0x5621c47ba6d9 - deno::lsp::documents::FileSystemDocuments::get::hbaa404aea81a490e
  28:     0x5621c47bbd92 - deno::lsp::documents::Documents::calculate_dependents_if_dirty::h41f9076dbcd19ae3
  29:     0x5621c47cf139 - deno::lsp::language_server::Inner::refresh_npm_specifiers::{{closure}}::h702108005336a52f
  30:     0x5621c48e2f59 - <deno::lsp::language_server::LanguageServer as tower_lsp::LanguageServer>::did_open::{{closure}}::hdc43060a3625329f
  31:     0x5621c47509e7 - tower_lsp::jsonrpc::router::Router<S,E>::method::{{closure}}::{{closure}}::{{closure}}::h10793fd21d989304
  32:     0x5621c4712183 - <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll::hbbf7dd7a34f3e9dd
  33:     0x5621c467e81e - <core::pin::Pin<P> as core::future::future::Future>::poll::h74b5aa41825bb15a
  34:     0x5621c467e81e - <core::pin::Pin<P> as core::future::future::Future>::poll::h74b5aa41825bb15a
  35:     0x5621c4588f0b - <tower_lsp::service::LspService<S> as tower_service::Service<tower_lsp::jsonrpc::Request>>::call::{{closure}}::h4cf88850486e4131
  36:     0x5621c476f404 - tower_lsp::transport::Server<I,O,L>::serve::{{closure}}::{{closure}}::h54e6216a2937f83b
  37:     0x5621c48c01ce - deno::run_subcommand::{{closure}}::h651d3a3d2b8c4c74
  38:     0x5621c48dbcfc - deno::main::{{closure}}::he9e79db54230805b
  39:     0x5621c465ece1 - tokio::task::local::LocalSet::run_until::{{closure}}::hf544c6e7cb432fcc
  40:     0x5621c458a204 - deno_runtime::tokio_util::run_local::h8a81533be0da6a76
  41:     0x5621c48d8807 - deno::main::hc178d56f2383b3b6
  42:     0x5621c45c24ff - std::sys_common::backtrace::__rust_begin_short_backtrace::h56f0e3242564fb44
  43:     0x5621c45c7df0 - std::rt::lang_start::{{closure}}::hb03437bda9bb01a0
  44:     0x5621c45107ec - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h9ab31282e87f134a
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:606:13
  45:     0x5621c45107ec - std::panicking::try::do_call::h42ddf5b01d0b4bc7
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
  46:     0x5621c45107ec - std::panicking::try::hfb70320d7386c61a
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
  47:     0x5621c45107ec - std::panic::catch_unwind::h978c9edbad2bb4d4
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
  48:     0x5621c45107ec - std::rt::lang_start_internal::{{closure}}::h04ede5bd2f26b553
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:148:48
  49:     0x5621c45107ec - std::panicking::try::do_call::ha6b9da35a0885c93
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
  50:     0x5621c45107ec - std::panicking::try::h3325520cab3a642e
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
  51:     0x5621c45107ec - std::panic::catch_unwind::h160beec6f047175b
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
  52:     0x5621c45107ec - std::rt::lang_start_internal::h79190e3a877a769d
                               at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:148:20
  53:     0x5621c493b205 - main
  54:     0x7f19307da290 - <unknown>
  55:     0x7f19307da34a - __libc_start_main
  56:     0x5621c34b1029 - _start
  57:                0x0 - <unknown>
[Error - 12:22:12 PM] The Deno Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

To Reproduce

  1. Start a new Deno project
  2. In .vscode/settings.json make sure you have:
    {
        "deno.enable": true,
        "deno.lint": true,
        "deno.importMap": "./import_map.json"
    }
  3. Create import_map.json with the following contents:
    {
        "grammy": "https://deno.land/x/grammy@v1.13.1/mod.ts",
        "@grammyjs/parse-mode": "https://deno.land/x/grammy_parse_mode@1.5.0/mod.ts"
    }
  4. In main.ts put the following:
    import { Bot, Context } from 'grammy'
    import { hydrateReply, parseMode } from '@grammyjs/parse-mode'
  5. Attempt to cache the missing dependencies. grammy works fine, but @grammyjs/parse-mode causes the crash.

System

Distro: EndeavourOS (Arch x86_64 on kernel 6.1.9-arch1-1) Deno: 1.30.2 Code version: 1.75.0

dsherret commented 1 year ago

This is #17640 and #17651.

Sorry, run deno upgrade --canary or downgrade to deno upgrade --version 1.30.0 if you are on M1 (since there are no canary builds).

watzon commented 1 year ago

You're awesome. Gonna try this out.