#2965·napi-rs

WASI builds not runs in bun and deno runtime

Author: jlucaso1Created Oct 17, 2025Updated Aug 23, 2026

The same code works fine with nodejs.

NAPI_RS_FORCE_WASI=error bun run benches/binary.ts
550 |         loadErrors.push(err)
551 |       }
552 |     }
553 |   }
554 |   if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
555 |     const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
                            ^
error: WASI binding not found and NAPI_RS_FORCE_WASI is set to error
      at /home/jlucaso/projects/whatsapp-rust-bridge/dist/index.js:555:23
      at loadAndEvaluateModule (2:1)

689 |             else {
690 |                 setupInstance(wasi, instance);
691 |             }
692 |         }
693 |         else {
694 |             wasi.initialize(instance);
                       ^
TypeError: wasi.initialize is not a function. (In 'wasi.initialize(instance)', 'wasi.initialize' is undefined)
 cause: error: Cannot find package 'whatsapp-rust-bridge-wasm32-wasi' from '/home/jlucaso/projects/whatsapp-rust-bridge/dist/index.js',

      at initialize (/home/jlucaso/projects/whatsapp-rust-bridge/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js:694:18)
      at <anonymous> (/home/jlucaso/projects/whatsapp-rust-bridge/node_modules/@emnapi/core/dist/emnapi-core.cjs.js:6556:38)
      at loadSyncCallback (/home/jlucaso/projects/whatsapp-rust-bridge/node_modules/@emnapi/core/dist/emnapi-core.cjs.js:6611:12)
      at loadNapiModuleImpl (/home/jlucaso/projects/whatsapp-rust-bridge/node_modules/@emnapi/core/dist/emnapi-core.cjs.js:6529:12)
      at instantiateNapiModuleSync (/home/jlucaso/projects/whatsapp-rust-bridge/node_modules/@emnapi/core/dist/emnapi-core.cjs.js:6629:12)
      at <anonymous> (/home/jlucaso/projects/whatsapp-rust-bridge/dist/index.wasi.cjs:48:86)
      at /home/jlucaso/projects/whatsapp-rust-bridge/dist/index.js:536:19

Bun v1.3.0 (Linux x64)

Reproduction: https://github.com/WhiskeySockets/whatsapp-rust-bridge/tree/error-reproduction-bun

bun install && bun run build bun run benches/binary.ts (the error occurs here) node benches/binary.ts (works fine)