Skip to content

Fix wizer preinit file access issue#99

Merged
vigoo merged 1 commit intomainfrom
preinit-fix
Apr 29, 2026
Merged

Fix wizer preinit file access issue#99
vigoo merged 1 commit intomainfrom
preinit-fix

Conversation

@vigoo
Copy link
Copy Markdown
Contributor

@vigoo vigoo commented Apr 29, 2026

Resolves #91

Root cause: During wizer pre-init, the wasm-rquickjs runtime evaluates the bundled user JS. When that bundle contains code like exa-js's node-fetch dep — which has try { require('encoding') } catch {} at module-eval time — the JS require shim walks node_modules via fs.readFileSync → Rust fs_openstd::fs::OpenOptions::open. The first such call triggers wasi-libc's lazy preopen-cache population against the empty wizer host environment (which provides no preopens), and the broken empty-cache state gets snapshotted by Wizer. After restore, std::fs::* operations fail with ENOENT scandir ‘/' even though wasmtime has provided real preopens.

Fix:

New WIZER_ACTIVE: AtomicBool static + is_wizer_active() helper, set to true for the duration of wizer_initialize().
Path-based fs ops (fs_open, fs_stat, fs_lstat, fs_readdir, fs_realpath, fs_readlink, fs_access) short-circuit with a synthetic ENOENT wizer_enoent_obj when the flag is set, never invoking std::fs::* and so never poisoning wasi-libc's preopen cache.

@vigoo vigoo merged commit c92a6b3 into main Apr 29, 2026
20 checks passed
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.

exa-js somehow interferes with builtin modules

2 participants