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

fetch panicked when accepting file scheme url #4038

Closed
keroxp opened this issue Feb 19, 2020 · 9 comments
Closed

fetch panicked when accepting file scheme url #4038

keroxp opened this issue Feb 19, 2020 · 9 comments

Comments

@keroxp
Copy link
Contributor

keroxp commented Feb 19, 2020

fetch("file:///path/to/file")
RUST_BACKTRACE=1 deno -A fetch.js
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/macros/mod.rs:15:40
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::panicking::panic
   9: deno::permissions::DenoPermissions::check_net_url
  10: deno::ops::fetch::op_fetch
  11: deno::state::State::core_op::{{closure}}
  12: deno_core::ops::OpRegistry::call
  13: deno_core::isolate::Isolate::dispatch_op
  14: deno_core::bindings::send
  15: <extern "C" fn(A0) .> R as rusty_v8::support::CFnFrom<F>>::mapping::c_fn
  16: _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
  17: _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
  18: _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
[1]    95204 abort      RUST_BACKTRACE=1 deno -A fetch.js
@keroxp
Copy link
Contributor Author

keroxp commented Feb 19, 2020

Should file url be valid for fetch? 🤔

@bartlomieju
Copy link
Member

Ref #2150. fetch shouldn't accept file:// URLs - it should error out in TS without calling Rust.

@bartlomieju bartlomieju added bug Something isn't working correctly good first issue Good for newcomers labels Feb 19, 2020
@ry
Copy link
Member

ry commented Feb 19, 2020

Is there a reason fetch shouldn't accept file urls?

@nayeemrmn
Copy link
Collaborator

@ry It's not a http server. I thought browsers generated responses around files and it would work but I just tried fetching relatively from a file:/// URL in chrome and it says it's not supported.

Fetch API cannot load file:///C:/Users/Nayeem/documents/3.png. URL scheme "file" is not supported.

@lucacasonato
Copy link
Member

lucacasonato commented Feb 19, 2020

@ry It's not a http server. I thought browsers generated responses around files and it would work but I just tried fetching relatively from a file:/// URL in chrome and it says it's not supported.

Fetch API cannot load file:///C:/Users/Nayeem/documents/3.png. URL scheme "file" is not supported.

It does work in Firefox though if you are on a file:// origin if I remember right. I'll test that in a second.

Edit: It doesn't work in FF anymore by default. Only with a flag. https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp

@kitsonk
Copy link
Contributor

kitsonk commented Feb 19, 2020

And discussed in #2150, Chrome allows it with a flag. Yes, it is for security issues in browsers, but I think the expectations in Deno are there as a server workload to just follow the Deno security model and allow it. It should respect the allow-read flag though versus the allow-net flag, IMO.

@gibsonhan
Copy link

has anyone claim this issue?

@bartlomieju bartlomieju removed bug Something isn't working correctly good first issue Good for newcomers labels Feb 19, 2020
@aduh95
Copy link
Contributor

aduh95 commented Feb 20, 2020

Note: same happen when using data: scheme.

@bartlomieju
Copy link
Member

Fixed in #4085, let's keep discussion of fetching file:// URLs in #2150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants