Skip to content

fix: use runtime filesystem for file:// requests#686

Open
fraidev wants to merge 6 commits intosupabase:mainfrom
fraidev:file-fetch-use-runtime-fs
Open

fix: use runtime filesystem for file:// requests#686
fraidev wants to merge 6 commits intosupabase:mainfrom
fraidev:file-fetch-use-runtime-fs

Conversation

@fraidev
Copy link
Copy Markdown

@fraidev fraidev commented Apr 10, 2026

Closes #640.

Problem

fetch() calls against file:// URLs (e.g. those resolved from npm: specifiers via import.meta.resolve) were reading from the host filesystem directly via tokio::fs,
bypassing the runtime's configured deno_fs. This caused them to fail in sandboxed environments where the runtime FS differs from the host FS.

The root cause: the startup snapshot bakes in a default FsFetchHandler backed by tokio::fs, and nothing was overriding it post-snapshot with an implementation that uses
OpState's FileSystemRc.

Solution

Mirrors the fix from denoland/deno#31814:

  • Override the handler at runtime init — immediately after JsRuntime::new, swap deno_fetch::Options::file_fetch_handler for an FsFetchHandler that reads from OpState's
    FileSystemRc.
  • Update the vendored FsFetchHandler — replace the tokio::fs + streaming path with fs.read_file_async(...), sourcing the FS from OpState instead of the host.

fraidev and others added 6 commits April 10, 2026 20:22
Fixes file:// fetch handling to use the runtime's configured
deno_fs instead of accessing host files directly.

Changes:
- Override snapshotted fetch handler with FsFetchHandler at runtime
- Update vendored fetch handler to read via deno_fs
- Add required dependencies for fs-backed fetch

Tests:
- Replace regression with real local npm file fetch case
- Cover file:// behavior matching actual failure mode
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.

"Using Wasm modules" edge function documentation code does not work

2 participants