Skip to content

fix(ext/fetch): include path and reason when fetching a file:// URL fails#35606

Merged
crowlKats merged 1 commit into
mainfrom
fix/fetch-file-error-message
Jun 30, 2026
Merged

fix(ext/fetch): include path and reason when fetching a file:// URL fails#35606
crowlKats merged 1 commit into
mainfrom
fix/fetch-file-error-message

Conversation

@bartlomieju

@bartlomieju bartlomieju commented Jun 29, 2026

Copy link
Copy Markdown
Member

Fetching a file:// URL that could not be opened always surfaced the
opaque NetworkError when attempting to fetch resource, discarding the
underlying filesystem error. The real reason (and which file) was lost
because fs.open_async errors were mapped with map_err(|_| NetworkError).

This is especially confusing for compiled binaries and deno desktop
apps. There, fetch(import.meta.resolve("./index.html")) on an asset
that was not embedded with --include resolves to a path inside the
compile 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:

Error fetching file 'file:///.../index.html': No such file or directory (os error 2)

The error remains a TypeError (file fetches are a Deno extension, and
keeping 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 --include is needed.

Fixes #35487.

…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
crowlKats merged commit 2f4bef6 into main Jun 30, 2026
137 checks passed
@crowlKats
crowlKats deleted the fix/fetch-file-error-message branch June 30, 2026 21:37
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

Successfully merging this pull request may close these issues.

deno desktop error fetching files

2 participants