Skip to content

js/wasmfs_fetch_patch.js is linked by nothing — a 357-line range-download fix that has never shipped #44

Description

@leehack

Problem

js/wasmfs_fetch_patch.js (357 lines) overrides Emscripten's WasmFS fetch backend to fix chunked range downloads for multi-GB cross-origin GGUFs. Nothing references it.

grep -rn wasmfs_fetch across the tree returns exactly one non-self reference:

CMakeLists.txt:139:    "-lwasmfs_fetch.js"

That is a different basename — it resolves to Emscripten's own src/lib/libwasmfs_fetch.js, which defines the same _wasmfs_create_fetch_backend_js key this file overrides. There is no --js-library, no -L, and no link_directories anywhere in CMakeLists.txt or scripts/build_bridge.sh.

Supporting evidence:

  • The file is unusable as anything but an emcc JS library: addToLibrary({ at line 12, Emscripten preprocessor macros ({{{ cDefs.EBADF }}}) near lines 328 and 341.
  • It is not copied into dist by scripts/build_bridge.sh:132-168.
  • git log -S wasmfs_fetch_patch shows nothing ever referenced it by name.

Meanwhile the stock backend it means to override is live: src/llama_webgpu_core.cpp:1324 calls wasmfs_create_fetch_backend(...) on the load-from-URL path, and docs/api.md:119-124 advertises remoteFetchThresholdBytes / allowAutoRemoteFetchBackend as supported.

So either the documented remote-fetch behaviour is running on the stock backend and this file is dead, or it was meant to ship and silently never did.

Options

A — Delete it. Low risk, removes the largest single piece of dead weight in the repo.

B — Wire it in. Append to CMakeLists.txt:127-140:

"--js-library=${CMAKE_CURRENT_SOURCE_DIR}/js/wasmfs_fetch_patch.js"

This is not a free two-line change: both files define the same symbol, so it depends on last-definition-wins override semantics; it changes the model-download path for both mem32 and mem64 builds; and CI currently runs an unpinned emsdk: latest. It needs a large-model browser smoke, not just a green build.

Either way

Add a scripts/verify_ci_reliability.py assertion so this cannot silently detach again — either that the file is absent, or that CMakeLists.txt names it.


Filed from a repository-wide code-quality audit against 909f14e. The evidence above was reproduced directly against the tree.

Triage decision gate

This remains an investigation rather than an implementation-ready bug fix. The current published bridge uses Emscripten's stock WasmFS fetch backend; the repository does not establish whether the detached override is still necessary.

Before choosing deletion or wiring it into the build:

  1. Reproduce the documented large, cross-origin, range-download path with the stock backend in both wasm32 and memory64.
  2. Confirm resume/chunk behavior and the remote-fetch fallback diagnostics.
  3. If stock behavior passes, delete the unused file and add a contract assertion that it stays absent.
  4. If stock behavior fails, wire the override only with an exact Emscripten pin, explicit link-order validation, and the same large-model browser smoke.

Do not merge a two-line --js-library change based only on a successful compile.

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

    priority:P3Useful cleanup or longer-term workquestionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions