fix(ext/fetch): include path and reason when fetching a file:// URL fails#35606
Merged
Conversation
…ails Fetching a file:// URL that could not be opened always surfaced the opaque "NetworkError when attempting to fetch resource", discarding the underlying filesystem error. This was especially confusing for compiled binaries and `deno desktop` apps, where `fetch(import.meta.resolve(...))` on an asset that was not embedded with `--include` resolves to a path inside the compile VFS and fails with no indication that the file is simply missing. Preserve the real error and the URL instead, so the message becomes e.g. "Error fetching file 'file:///.../index.html': No such file or directory (os error 2)".
crowlKats
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fetching a
file://URL that could not be opened always surfaced theopaque
NetworkError when attempting to fetch resource, discarding theunderlying filesystem error. The real reason (and which file) was lost
because
fs.open_asyncerrors were mapped withmap_err(|_| NetworkError).This is especially confusing for compiled binaries and
deno desktopapps. There,
fetch(import.meta.resolve("./index.html"))on an assetthat was not embedded with
--includeresolves to a path inside thecompile VFS and fails with no hint that the file is simply missing, as
reported in #35487.
This preserves the underlying error and the URL, so the message now
reads, for example:
The error remains a
TypeError(file fetches are a Deno extension, andkeeping the class matches the previous behavior and fetch semantics for
network errors). The path under the compile temp directory now also
serves as a strong hint that
--includeis needed.Fixes #35487.