Skip to content

Harden the worker offload path - #49

Merged
jcbrand merged 3 commits into
masterfrom
wasm-single-file-node-esm
Aug 5, 2026
Merged

Harden the worker offload path#49
jcbrand merged 3 commits into
masterfrom
wasm-single-file-node-esm

Conversation

@jcbrand

@jcbrand jcbrand commented Aug 5, 2026

Copy link
Copy Markdown
Member

No description provided.

jcbrand added 3 commits August 5, 2026 13:18
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
jcbrand force-pushed the wasm-single-file-node-esm branch from ee06fd2 to 05c7eb5 Compare August 5, 2026 11:18
@jcbrand jcbrand changed the title Off-main-thread crypto and a wasm-free worker-client build Harden the worker offload path Aug 5, 2026
@jcbrand
jcbrand merged commit e9cb2f3 into master Aug 5, 2026
3 checks passed
@jcbrand
jcbrand deleted the wasm-single-file-node-esm branch August 5, 2026 11:20
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.

1 participant