Skip to content

WasmFS Fetch backend corrupts file reads with custom chunk size when HTTP Range is unsupported #28001

Open

Description

@Temtaime

Version of emscripten/emsdk: 6.0.12

Description:

When using wasmfs_create_fetch_backend() with an HTTP server that does not support Range requests (emrun --no_browser), only the first chunk of the file is read correctly. All subsequent bytes are zero.

fread() reports the correct number of bytes read, despite the data being incomplete.

This happens regardless of the configured chunk size:

  • 64 * 1024 (64 KiB): files larger than 64 KiB are truncated to the first chunk.
  • 0 (default 16 MiB): files larger than 16 MiB are truncated to the first chunk.

Minimal setup:

backend_t backend = wasmfs_create_fetch_backend(
    "http://localhost:8080/assets/",
    64 * 1024
);

wasmfs_create_directory("/assets", 0777, backend);
wasmfs_create_file("/assets/test.bin", 0444, backend);

Reading /assets/test.bin via fread() reproduces the issue when the file exceeds the chunk size.

Expected behavior: The entire file is read correctly, even when the server does not support HTTP Range requests.

Actual behavior: Only the first chunk contains valid data. The remaining bytes are zero, while fread() reports a successful full read.

Suspected cause: Incorrect handling of multi-chunk files when falling back to full-file downloads on servers without HTTP Range support.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions