fix(napi): wasi debug compile error#3081
Conversation
📝 WalkthroughWalkthroughThe PR tightens conditional compilation gates to exclude WebAssembly targets from debug-assertion code paths in the NAPI bindgen runtime, and adds a cargo check step for WASM builds in the CI workflow. Additionally, the environment cleanup hook registration is gated to exclude the noop feature under WASM targets. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used🧠 Learnings (7)📓 Common learnings📚 Learning: 2025-11-25T09:31:23.877ZApplied to files:
📚 Learning: 2025-11-25T09:31:23.877ZApplied to files:
📚 Learning: 2025-11-25T09:31:23.877ZApplied to files:
📚 Learning: 2025-11-25T09:31:23.877ZApplied to files:
📚 Learning: 2025-11-25T09:31:23.877ZApplied to files:
📚 Learning: 2025-11-25T09:31:23.877ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (28)
🔇 Additional comments (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a compilation error that occurs when building the napi crate for WASI (WebAssembly System Interface) targets in debug mode. The issue stems from the use of thread-local storage and mutexes, which are not available in WebAssembly environments.
- Adds
not(target_family = "wasm")guards to debug assertion code that uses thread-local storage - Ensures the
BUFFER_DATAthread-local variable and its usage are excluded from WASM builds - Adds a CI check to catch similar issues early in the WASI build pipeline
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/napi/src/env.rs | Adds not(feature = "noop") guard to WASM-specific cleanup hook implementation |
| crates/napi/src/bindgen_runtime/mod.rs | Excludes WASM from debug buffer tracking in drop_buffer and drop_buffer_slice functions |
| crates/napi/src/bindgen_runtime/js_values/buffer.rs | Excludes WASM from all debug buffer tracking code including imports, thread-local declaration, and usage sites |
| .github/workflows/test-release.yaml | Adds cargo check step for WASI target with all features enabled to catch compile errors earlier |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
96511ee to
ffc8cb9
Compare

Note
Addresses WASI debug build issues and strengthens WASI CI.
wasmfrom debug-only buffer tracking and GC cleanup paths (js_values/buffer.rs,bindgen_runtime/mod.rs) via#[cfg(all(debug_assertions, not(windows), not(target_family = "wasm")))]#[cfg(all(target_family = "wasm", not(feature = "noop")))]inenv.rscargo check -p napi --all-features --target wasm32-wasip1-threadswhenRUSTFLAGS == '--cfg tokio_unstable'intest-node-wasiWritten by Cursor Bugbot for commit ffc8cb9. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.