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

main thread panics if you pass an absolute path to import() #4641

Closed
envis10n opened this issue Apr 5, 2020 · 7 comments
Closed

main thread panics if you pass an absolute path to import() #4641

envis10n opened this issue Apr 5, 2020 · 7 comments
Assignees
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed

Comments

@envis10n
Copy link

envis10n commented Apr 5, 2020

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.

@kitsonk
Copy link
Contributor

kitsonk commented Apr 5, 2020

Can you provide the actual panic?

@envis10n
Copy link
Author

envis10n commented Apr 5, 2020

[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" }

@kitsonk
Copy link
Contributor

kitsonk commented Apr 6, 2020

@envis10n thanks!

It is a bug, this:

_ => unreachable!(),

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

@bartlomieju
Copy link
Member

Actually it might be related to #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.

@bartlomieju
Copy link
Member

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.

@bartossh
Copy link
Contributor

bartossh commented Apr 6, 2020

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

@bartlomieju bartlomieju self-assigned this Apr 6, 2020
@bartlomieju bartlomieju added bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed labels May 21, 2020
@nayeemrmn
Copy link
Collaborator

Looks fixed in 1.7.4:

error: Uncaught (in promise) TypeError: Unsupported scheme "c" for module "c:\Users\Nayeem\projects\deno\temp2.ts". Supported schemes: [
    "data",
    "file",
    "http",
    "https",
]

@kitsonk kitsonk closed this as completed Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants