Harden the worker offload path - #49
Merged
Merged
Conversation
The reply protocol inferred success from a missing error field, so a reply carrying neither resolved the job. verifySignature reports success by resolving with no value, which made an unintelligible reply indistinguishable from a valid signature. The worker now sends `ok: true` on success and a non-empty error string on failure. The manager resolves only on ok === true and treats anything else as a transport failure.
A timeout rejected every pending job, terminated the worker, and latched the backend to the fallback for good. The default build then moved all private key operations back onto the main thread, and the worker-client build, whose fallback throws, failed every later operation for the lifetime of the page. A timer firing more than 250ms past its deadline now counts as a stalled main thread and grants the job one more interval. A lone timeout fails only its own operation. The worker is dropped after two consecutive timeouts or a crash, then rebuilt on a later operation with backoff. stopWorker() remains the only permanent stop.
A worker failure moves every private key operation back onto the main
thread, which the default build announced with a single console.error.
Now that a dropped worker is rebuilt automatically, offloading can stop
and resume several times in one page, and none of that was observable
to the consumer.
startWorker takes an onStatusChange callback that fires on each transition
with { offloaded, error }. Logging follows the same edges, so a repeatedly
failing worker is announced once rather than never or every time.
jcbrand
force-pushed
the
wasm-single-file-node-esm
branch
from
August 5, 2026 11:18
ee06fd2 to
05c7eb5
Compare
worker-client build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.