Skip to content

fix(nodejs): treat NAPI_RS_FORCE_WASI as truthy only when set to 'true'#3519

Merged
wjones127 merged 1 commit into
lancedb:mainfrom
nuthalapativarun:fix/3267-napi-force-wasi-truthy
Jun 9, 2026
Merged

fix(nodejs): treat NAPI_RS_FORCE_WASI as truthy only when set to 'true'#3519
wjones127 merged 1 commit into
lancedb:mainfrom
nuthalapativarun:fix/3267-napi-force-wasi-truthy

Conversation

@nuthalapativarun

Copy link
Copy Markdown
Contributor

Summary

Fixes the NAPI_RS_FORCE_WASI=false issue by upgrading @napi-rs/cli from 3.5.1 to 3.7.0.

Closes #3267

Root Cause

In the native.js loader generated by napi build, the check was:

if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {

In JavaScript, any non-empty string is truthy, so NAPI_RS_FORCE_WASI=false (a non-empty string) inadvertently triggered the WASI fallback path. This caused an ENOENT error when lancedb.wasi.cjs was not present.

Fix

@napi-rs/[email protected] (napi-rs/napi-rs#3236) introduced a tri-state check in the template that generates native.js:

Before (generated by @napi-rs/[email protected]):

if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {

After (generated by @napi-rs/[email protected]):

const forceWasi =
  process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error'

if (!nativeBinding || forceWasi) {

Only the literal string 'true' (or 'error' for strict mode) now activates the WASI path. All other values, including 'false', '0', or an unset variable, behave as if WASI is not forced.

Changes

  • nodejs/package.json: bump @napi-rs/cli from 3.5.1 to 3.7.0
  • nodejs/package-lock.json / nodejs/pnpm-lock.yaml: update lock files to match

The fix is in the upstream napi-rs tool; the generated native.js is not committed to this repository and is produced at build time by napi build.

Upgrade @napi-rs/cli from 3.5.1 to 3.7.0, which fixes the truthy string
check in the generated native.js loader. Previously, setting
NAPI_RS_FORCE_WASI=false caused the WASI fallback to trigger because any
non-empty string is truthy in JavaScript. The fix in napi-rs/[email protected]
uses an explicit comparison (=== 'true' || === 'error'), so only the
literal string 'true' activates the WASI path.

Closes lancedb#3267
@github-actions github-actions Bot added the bug Something isn't working label Jun 9, 2026
@wjones127
wjones127 merged commit 9c12fb6 into lancedb:main Jun 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(node): NAPI_RS_FORCE_WASI=false triggers WASI fallback due to truthy string check

3 participants