Deno: main thread panics if you pass an absolute path to import()

Created on 5 Apr 2020  路  6Comments  路  Source: denoland/deno

I had made an error with the way I was setting up the path for dynamic imports, and it was crashing showing a thread panic on the rust side. I checked the path, and it was using the actual absolute path on windows (C:...). I fixed this to use the relative path, and it loads fine. The problem, in my opinion, is that it panics when the path provided is not using the file:/// prefix, or a relative path.

bug core

Most helpful comment

@envis10n thanks!

It is a bug, this:

https://github.com/denoland/deno/blob/6720a0dc02dc5a93472520e6d23ca033d7ec9d88/cli/state.rs#L372

Should return an OpError instead of using the unreachable macro. Should be an easy fix for someone if they wanted to contribute to Deno.

All 6 comments

Can you provide the actual panic?

[Code]

const imp = await import(`${Deno.cwd()}\\commands\\echo.ts`);

console.log(imp);

[Panic]

thread 'main' panicked at 'internal error: entered unreachable code', cli\state.rs:361:12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

[Output after adding file:/// to the beginning of the path]

Module { default: [AsyncFunction: default], Symbol(Symbol.toStringTag): "Module" }

@envis10n thanks!

It is a bug, this:

https://github.com/denoland/deno/blob/6720a0dc02dc5a93472520e6d23ca033d7ec9d88/cli/state.rs#L372

Should return an OpError instead of using the unreachable macro. Should be an easy fix for someone if they wanted to contribute to Deno.

Actually it might be related to https://github.com/denoland/deno/issues/3355. The unreachable!() statement is there for a reason - it shouldn't ever be hit as "previous" layers should resolve or reject the invalid specifier.

Actually it's definitely #3355 I had encountered this problem a while ago - quick solution was to prefix the import with file://, but we need to fix the underlying problem.

@bartlomieju shall I remove / close #4646 PR and work it out some other way ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doutchnugget picture doutchnugget  路  3Comments

motss picture motss  路  3Comments

ry picture ry  路  3Comments

watilde picture watilde  路  3Comments

justjavac picture justjavac  路  3Comments