denoland / deno

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

Deno panic in vscode #20363

Open marvinhagemeister opened 1 year ago

marvinhagemeister commented 1 year ago

Just opened vscode in a new project and got a panic:

============================================================
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.36.4
Args: ["/Users/marvinhagemeister/.deno/bin/deno", "lsp"]

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', cli/npm/resolvers/local.rs:179:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Error - 20:28:01] 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.
nayeemrmn commented 1 year ago

We can just remove the unwrap from something more graceful at https://github.com/denoland/deno/blob/c0617d11f6391f1b1b3afffe0152c73b5989ab80/cli/npm/resolvers/local.rs#L179 But basically this happens because somehow that loop was invoked with a path that was outside of self.root_node_modules_path. resolve_package_folder_from_package() confirms that referrer is within self.root_node_modules_path but then it canonicalizes it. And I noticed self.root_node_modules_path isn't ever canonicalized.

So maybe this happens when the root node_modules exists within a symlink?

cc @dsherret

skybrian commented 7 months ago

I saw something like this happen after renaming my Deno project folder. Deleting node_modules fixed it.

(This was using Deno 1.41.0.)