Skip to content

fix(ipc-runtime): terminate a wasm main worker that fails to start - #25763

Merged
just-mitch merged 1 commit into
mitch/zkm-1782-bbjs-gives-ipads-and-desktop-mode-iphones-the-desktop-srsfrom
mitch/zkm-1784-a-bbjs-wasm-main-worker-that-fails-to-start-stays-alive
Nov 7, 2026
Merged

just-mitch merged 1 commit into
mitch/zkm-1782-bbjs-gives-ipads-and-desktop-mode-iphones-the-desktop-srsfrom
mitch/zkm-1784-a-bbjs-wasm-main-worker-that-fails-to-start-stays-alive

Conversation

@just-mitch

@just-mitch just-mitch commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Before this PR, when the bb.js wasm main worker failed to start, the worker stayed alive. In Node.js, the process did not exit, and each retry of Barretenberg.initSingleton left one more worker.

After this PR, WasmFfiBackend.create terminates the worker, and then throws the start error.

Ticket: ZKM-1784 (parent ZKM-1779). Parent PR: #25761.

@just-mitch
just-mitch added this pull request to stack #25762 November 4, 2026 20:26
@just-mitch
just-mitch force-pushed the mitch/zkm-1784-a-bbjs-wasm-main-worker-that-fails-to-start-stays-alive branch from dc3e36c to 82407d5 Compare November 4, 2026 20:40
@just-mitch
just-mitch marked this pull request as ready for review November 5, 2026 01:17
@just-mitch
just-mitch removed this pull request from stack #25762 November 5, 2026 16:52
@just-mitch
just-mitch added this pull request to stack #25766 November 5, 2026 16:53
@just-mitch
just-mitch force-pushed the mitch/zkm-1784-a-bbjs-wasm-main-worker-that-fails-to-start-stays-alive branch from 82407d5 to 7047073 Compare November 5, 2026 16:53
@AztecBot

AztecBot commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Flakey Tests

🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/072a8ec311817cff�072a8ec311817cff8;;�): cd labs && export root= ci3= &&  yarn-project/end-to-end/scripts/run_test.sh simple src/multi-node/slashing/broadcasted_invalid_block_proposal_slash.test.ts (246s) (code: 0) group:e2e-p2p-epoch-flakes

just-mitch added a commit that referenced this pull request Nov 5, 2026
…mory maximum (#25760)

Before this PR, an iPad and an iPhone with Request Desktop Website on
got the desktop wasm memory maximum of 4 GiB, because they send a Mac
user agent. On an iPad, the zk.money PXE failed with "RangeError: Out of
memory".

After this PR, these devices get the iOS maximum of 1 GiB (`2 ** 14`
pages) when the page creates the backend.

## The thread that creates the backend resolves the memory maximum

A worker has no `navigator.maxTouchPoints`, so the main worker cannot
detect these devices. `WasmFfiBackend.create` resolves the maximum and
sends it in the `init` message. A maximum that the caller sets still has
priority. Evidence: the Pointer Events WebIDL declares `maxTouchPoints`
on `Navigator` only.

## `isIos` in `@aztec-foundation/ipc-runtime/wasm`

It matches `iPad` or `iPhone`, or a `Macintosh` user agent with
`maxTouchPoints > 1`. It is not in the package root, which imports
`node:net` and `node:child_process`.

## Other changes

- The iOS and desktop values stay the same.
- `WasmPlatform.maximumMemoryPages` documents the thread that reads it.

## Known issues

- A backend that a Web Worker creates still gets the desktop maximum.
The wallet sets the values explicitly in ZKM-1780.

Ticket: ZKM-1779. Child PRs: #25761, #25763.
Before, the worker stayed alive after init-error: in Node.js it kept the process from exiting, and each retry leaked one more worker.

ZKM-1784
@just-mitch
just-mitch force-pushed the mitch/zkm-1784-a-bbjs-wasm-main-worker-that-fails-to-start-stays-alive branch from 7047073 to 9726ecf Compare November 5, 2026 17:47
@just-mitch
just-mitch merged commit d2ead45 into next Nov 7, 2026
15 checks passed
@just-mitch
just-mitch deleted the mitch/zkm-1784-a-bbjs-wasm-main-worker-that-fails-to-start-stays-alive branch November 7, 2026 18:50
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.

3 participants