Skip to content

An ordinary error from a worker call moves the bridge to the main thread #117

Description

@leehack

In worker mode, an ordinary API error from the worker is handled as a worker failure, and the bridge moves to the main thread for the rest of the session.

Repro (same on v0.1.44 and v0.1.47, wasm32 and wasm64):

await bridge.tokenize('hi', true); // before loadModelFromUrl
// rejects: "No model loaded. Call loadModelFromUrl first."
await bridge.loadModelFromUrl(modelUrl, { nGpuLayers: 0 });
// window.__llamadartBridgeWorkerFallbackReason === 'No model loaded. Call loadModelFromUrl first.'
// model metadata: llamadart.webgpu.execution === 'main-thread'

Without the early tokenize, execution stays on the worker.

Cause: _tokenizeUnlocked (js/src/llama_webgpu_bridge.js:7392-7406 at 64ba825) calls _disableWorkerFallback(error) for any rejection from _callWorker, without checking what kind of error it is. Other wrappers with the same catch pattern are worth checking.

Expected: fall back only on worker failures (crash, init or transport errors, and the recoverable classes the bridge already recognizes). Rethrow ordinary API errors such as "No model loaded" unchanged, and keep the worker.

Impact: low for llamadart. Its checks found no llamadart call that reaches the bridge before a model loads. Found while validating the bridge pin bump in leehack/llamadart#620.

No activity

Activity on this issue will appear here.

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

    bugSomething isn't workingpriority:P3Useful cleanup or longer-term work

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions