-
Notifications
You must be signed in to change notification settings - Fork 25
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
Deno.emit panics with some types of custom scheme URLs #43
Comments
The first two I don't believe are valid URLs. Any custom schemes that aren't specified require to be in the format of We shouldn't panic though, we should reject the promise. |
Does the second use url::Url;
let url = Url::parse("custom://a.ts").unwrap();
assert!(!url.cannot_be_a_base());
let url = Url::parse("custom://a//a.ts").unwrap();
assert!(!url.cannot_be_a_base()); Also: |
If that is the case, @kt3k can you provide more details about what panics are happening and where? |
The first one comes from here https://github.com/denoland/deno/blob/81d73f2/cli/module_graph.rs#L1821, and the second one from here https://github.com/denoland/deno/blob/1a9209d/cli/tsc/99_main_compiler.js#L268
After reading @nayeemrmn's comment carefully, I feel both could be valid urls 🤔 |
Yes, I agree... what appears to be failing is the media type detection. It is detected here: which comes from: So the proper fix would be to add examples of these valid, but incorrectly typed specifiers to the test cases and fix the media type detection. That should fix both panics I suspect. |
@kitsonk Sorry for changing the opinion again about this, but after checking the URL spec and the behaviors of whatwg-url (npm module) and rust-url (our depencency), I think the parsed result of |
@kt3k I am not sure I agree. It is entirely up to us how we decide to assign a media type to a URL. Why wouldn't the logic of "if the pathname is empty, attempt to look at the hostname" be inappropriate? We could also limit it only to schemas that aren't "known" like |
I'm now working towards this direction. I was able to change the media type of BTW although denoland/deno#9302 doesn't address this issue, I think it still addresses another problem (I updated the test case to illustrate what it fixes). So could you PTAL when you have time? |
That is because we stringify the module specifier when we go into TypeScript, and it would appear that |
Memo: I found that typescript normalizes the path during handling op_load call, ref: https://github.com/microsoft/TypeScript/blob/0383b5cb4c96083c12ea1453bf129fe675abaac9/src/compiler/program.ts#L2230-L2232 const id = "https://example.com//a.ts";
await Deno.emit(id, { sources: { [id]: "" } }); In the above call Now this looks very difficult to resolve... |
@kt3k I had some challenges with this before, in a different way. We might be able to work around it. We already have a construct for dealing with special handling of root modules because TypeScript refuses to accept some module specifiers as root modules. |
I tested some patterns of custom scheme urls as input of Deno.emit, and I found the following 2 cause panic:
(These types of urls are used in dext. ref: https://github.com/lucacasonato/dext.ts/blob/8483d19/src/plugins/dext.ts#L46 )
On the other hand, the following compiles without problem:
What do you think are the expected behaviors for the above 2 cases?
The text was updated successfully, but these errors were encountered: