Uh oh!
There was an error while loading. Please reload this page.
Conversation
Contributor
abk404
marked this pull request as ready for review
August 17, 2026 10:41
Ticket: POL-929
davidkaplanbitgo
approved these changes
Aug 17, 2026
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 freeto 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.
fix(sdk-core): batch bulkAcceptShare to prevent WASM OOM in browser
Problem
Users with a large number of shared wallets (e.g. 96) get the following error when clicking "Accept Keys" in Kintsugi:
Root cause:
bulkAcceptSharedecrypts each wallet's shared keychain using Argon2id — a WASM-based KDF. Eachdecryptcall creates a freshWebAssembly.Instancethat commits ~64 MB of real memory and reserves ~2 GB of virtual address space. WithPromise.alllaunching all shares simultaneously, a user with 96 wallets triggers ~192 concurrent WASM instances (decrypt + re-encrypt per share) — exhausting the browser tab's virtual address space (~256 GB on V8) and crashing.This was introduced in WCN-174 (
feat: make encrypt/decrypt async) when the original sequentialflatMaploop was converted toPromise.allto handle the newly async encrypt/decrypt calls, without accounting for the per-call WASM memory cost.Before (broken):
Fix
Process shares in batches of 16. At most 32 WASM instances are alive at once (~2 GB real, ~64 GB virtual), well within browser limits.
Batch size rationale: Benchmarking shows a Chrome tab on a modern machine hits OOM at ~124 concurrent WASM instances (~248 GB virtual). A typical 8–16 GB machine under normal browser load has a lower effective ceiling.
BATCH_SIZE = 16→ 32 concurrent instances → ~2 GB RAM committed — safe across devices while being 4× faster than a conservative batch of 4.After:
Per-share logic is identical — no behaviour change for any individual share, no API changes.
Performance impact
For 96 wallets: 6 batches × ~3s per batch ≈ ~18s vs. a crash. Acceptable for a one-time accept-keys action. Previously when the flow was synchronous (before WCN-174), latency was similar — the async conversion didn't reduce total time for a single user, it just introduced the concurrency bug.
Testing
encryptionVersionthreading tests continue to passBATCH_SIZERelated