Skip to content

fix(sdk-lib-mpc): lazy-load wasm-mps to fix browser DSG#9132

Open
Marzooqa wants to merge 1 commit into
masterfrom
marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require
Open

fix(sdk-lib-mpc): lazy-load wasm-mps to fix browser DSG#9132
Marzooqa wants to merge 1 commit into
masterfrom
marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require

Conversation

@Marzooqa

Copy link
Copy Markdown
Contributor

Static top-level import compiled to synchronous require() in CJS, causing fs.readFileSync at module init — unavailable in browser. DSG failed with: Cannot read properties of undefined (reading '__wbindgen_add_to_stack_pointer')

Similar to the lazy-load pattern from DKG fix:

  • Browser: await import('@bitgo/wasm-mps/web') + webWasm.default()
  • Node: await import('@bitgo/wasm-mps')
  • initDsg() and restoreSession() made async
  • eddsaMPCv2.ts call sites updated to await initDsg()
  • Tests updated accordingly

WCI-866

@linear-code

linear-code Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

WCI-866

@Marzooqa Marzooqa force-pushed the marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require branch 2 times, most recently from f64215a to 1e9904e Compare June 29, 2026 11:52
@Marzooqa Marzooqa marked this pull request as ready for review June 29, 2026 12:23
@Marzooqa Marzooqa requested review from a team as code owners June 29, 2026 12:23
Comment thread modules/sdk-core/test/unit/bitgo/utils/tss/eddsa/verifyMpsDerivation.ts Outdated
typeof window !== 'undefined' &&
/* checks for electron processes */
!window.process &&
!window.process?.['type']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!window.process?.['type'] is redundant here
Since the previous condition already implies that window.process would be undefined

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mirrors DKG, will have to clean both of it together as a follow-up

Static top-level import compiled to synchronous require() in CJS,
causing fs.readFileSync at module init — unavailable in browser.
DSG failed with: Cannot read properties of undefined
(reading '__wbindgen_add_to_stack_pointer')

Mirrors the lazy-load pattern from WCI-244 (DKG fix):
- Browser: await import('@bitgo/wasm-mps/web') + webWasm.default()
- Node: await import('@bitgo/wasm-mps')
- initDsg() and restoreSession() made async
- eddsaMPCv2.ts call sites updated to await initDsg()
- Tests updated accordingly

WCI-866

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Marzooqa Marzooqa force-pushed the marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require branch from 1e9904e to e7bdb1c Compare June 29, 2026 14:43
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.

2 participants