Skip to content

Comments

fix(napi): skip debug buffer tracking on wasm targets#3078

Merged
graphite-app[bot] merged 1 commit intomainfrom
bisect/cfg-only
Dec 30, 2025
Merged

fix(napi): skip debug buffer tracking on wasm targets#3078
graphite-app[bot] merged 1 commit intomainfrom
bisect/cfg-only

Conversation

@Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Dec 30, 2025

Note

Adjusts debug-only buffer tracking to exclude WebAssembly targets.

  • Adds not(target_family = "wasm") to #[cfg(all(debug_assertions, not(windows)))] guards
  • Applies to BUFFER_DATA thread_local in buffer.rs and duplicate-pointer checks in arraybuffer.rs (including typed array slices and Uint8ClampedSlice)
  • Prevents wasm builds from using debug TLS-based pointer checks/panics

Written by Cursor Bugbot for commit ac6a276. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Chores
    • Refined platform-specific debug behavior to disable certain debug-only buffer checks on WebAssembly builds while preserving them on other platforms; public APIs remain unchanged.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 30, 2025 03:18
@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Added WebAssembly exclusion to several debug-only conditional compilation attributes so buffer/ArrayBuffer debug validation blocks and a thread-local buffer declaration are omitted when compiling for WASM targets; no public APIs or function signatures were changed.

Changes

Cohort / File(s) Summary
WASM compilation gates
crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs, crates/napi/src/bindgen_runtime/js_values/buffer.rs
Added not(target_family = "wasm") to existing cfg(all(debug_assertions, not(windows), ...)) checks, excluding WASM targets from debug-only buffer-data validation code and a thread-local BUFFER_DATA declaration. Affects from_data, from_external, and impl_from_slice-related blocks; no public signatures changed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 I nudge the gates with careful paws,

Debug hops skip the WASM cause,
Silent checks on other lands,
Lighter builds at tiny hands,
A rabbit's wink — safe, small claws.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding wasm target exclusions to debug buffer tracking guards in the napi crate.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 791b076 and e55bc34.

📒 Files selected for processing (2)
  • crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs
  • crates/napi/src/bindgen_runtime/js_values/buffer.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs
  • crates/napi/src/bindgen_runtime/js_values/buffer.rs
⏰ 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). (40)
  • GitHub Check: aarch64-pc-windows-msvc - node@22 - toolchain@ stable
  • GitHub Check: i686-pc-windows-msvc - node@22 - toolchain@ stable
  • GitHub Check: aarch64-apple-darwin - node@22 - toolchain@ stable
  • GitHub Check: aarch64-pc-windows-msvc - node@24 - toolchain@ stable
  • GitHub Check: x86_64-unknown-linux-gnu - node@22 - toolchain@ 1.88.0
  • GitHub Check: x86_64-pc-windows-msvc - node@22 - toolchain@ stable
  • GitHub Check: x86_64-unknown-linux-gnu - node@24 - toolchain@ 1.88.0
  • GitHub Check: x86_64-pc-windows-msvc - node@24 - toolchain@ stable
  • GitHub Check: x86_64-pc-windows-msvc - node@20 - toolchain@ stable
  • GitHub Check: x86_64-unknown-linux-gnu - node@24 - toolchain@ stable
  • GitHub Check: aarch64-apple-darwin - node@24 - toolchain@ stable
  • GitHub Check: i686-pc-windows-msvc - node@24 - toolchain@ stable
  • GitHub Check: aarch64-apple-darwin - node@20 - toolchain@ stable
  • GitHub Check: x86_64-unknown-linux-gnu - node@22 - toolchain@ stable
  • GitHub Check: x86_64-unknown-linux-gnu - node@20 - toolchain@ stable
  • GitHub Check: Build only test - loongarch64-unknown-linux-gnu
  • GitHub Check: Build only test - aarch64-linux-android
  • GitHub Check: build - aarch64-unknown-linux-gnu
  • GitHub Check: build - s390x-unknown-linux-gnu
  • GitHub Check: Build only test - armv7-linux-androideabi
  • GitHub Check: Build only test - aarch64-unknown-linux-ohos
  • GitHub Check: build - x86_64-unknown-linux-gnu
  • GitHub Check: stable - armv7-unknown-linux-gnueabihf - node@22
  • GitHub Check: build - powerpc64le-unknown-linux-gnu
  • GitHub Check: build-and-test-msys2 (MINGW64)
  • GitHub Check: Memory leak detect job
  • GitHub Check: build - x86_64-unknown-linux-musl
  • GitHub Check: Build only test - riscv64gc-unknown-linux-gnu
  • GitHub Check: build - aarch64-unknown-linux-musl
  • GitHub Check: Test freebsd target
  • GitHub Check: build-and-test-msys2 (CLANG64)
  • GitHub Check: build-and-test-msys2 (UCRT64)
  • GitHub Check: Test node wasi target (--cfg tokio_unstable)
  • GitHub Check: Test node wasi target
  • GitHub Check: Zig-Cross-Compile-On-Linux (aarch64-apple-darwin)
  • GitHub Check: Zig-Cross-Compile-On-Linux (aarch64-unknown-linux-musl)
  • GitHub Check: Zig-Cross-Compile-On-Linux (armv7-unknown-linux-musleabihf)
  • GitHub Check: Zig-Cross-Compile-On-Linux (x86_64-unknown-linux-musl)
  • GitHub Check: ASAN - windows-latest
  • GitHub Check: ASAN - ubuntu-24.04

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91f19f4 and 791b076.

📒 Files selected for processing (2)
  • crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs
  • crates/napi/src/bindgen_runtime/js_values/buffer.rs
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-25T09:31:23.877Z
Learnt from: CR
Repo: napi-rs/napi-rs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T09:31:23.877Z
Learning: Applies to /crates/**/*.rs : Use `#[napi]` attribute on impl blocks to define classes exported to JavaScript/TypeScript

Applied to files:

  • crates/napi/src/bindgen_runtime/js_values/buffer.rs
  • crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs
📚 Learning: 2025-11-25T09:31:23.877Z
Learnt from: CR
Repo: napi-rs/napi-rs PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T09:31:23.877Z
Learning: Applies to /crates/**/*.rs : Use `#[napi(js_name = "...")]` attribute to rename Rust items in JavaScript/TypeScript

Applied to files:

  • crates/napi/src/bindgen_runtime/js_values/buffer.rs
  • crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs
⏰ 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). (7)
  • GitHub Check: aarch64-pc-windows-msvc - node@24 - toolchain@ stable
  • GitHub Check: aarch64-pc-windows-msvc - node@22 - toolchain@ stable
  • GitHub Check: Build only test - aarch64-unknown-linux-ohos
  • GitHub Check: Zig-Cross-Compile-On-Linux (aarch64-apple-darwin)
  • GitHub Check: ASAN - ubuntu-24.04
  • GitHub Check: Memory leak detect job
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (1)
crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs (1)

151-151: LGTM - Consistent WASM exclusion for debug buffer validation.

All six cfg attribute changes consistently add not(target_family = "wasm") to the existing debug assertion conditions for BUFFER_DATA usage sites. The changes correctly prevent buffer tracking checks from compiling on WASM targets.

However, these changes depend on the fix for the critical issue in buffer.rs where the usage sites also need to be updated to match the BUFFER_DATA definition.

Also applies to: 232-232, 919-919, 1024-1024, 1638-1638, 1735-1735

Copy link
Member Author

Brooooooklyn commented Dec 30, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • ready-to-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds not(target_family = "wasm") to conditional compilation attributes for debug assertion code that uses thread_local! storage. The changes prevent compilation of thread-local buffer tracking code on WASM targets, where thread-local storage is problematic.

  • Updated BUFFER_DATA thread_local declaration in buffer.rs to exclude WASM targets
  • Updated all 6 usages of BUFFER_DATA in arraybuffer.rs to exclude WASM targets

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/napi/src/bindgen_runtime/js_values/buffer.rs Updated cfg attribute on BUFFER_DATA thread_local declaration to exclude WASM targets
crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs Updated cfg attributes on all 6 usages of BUFFER_DATA to exclude WASM targets, ensuring consistency with the declaration in buffer.rs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Brooooooklyn Brooooooklyn changed the title bisect: cfg attribute changes only - add not(target_family = wasm) fix(napi): check NAPI status before using pointers in fallback paths Dec 30, 2025
@Brooooooklyn Brooooooklyn changed the title fix(napi): check NAPI status before using pointers in fallback paths fix(napi): skip debug buffer tracking on wasm targets Dec 30, 2025
@graphite-app
Copy link

graphite-app bot commented Dec 30, 2025

Merge activity

<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adjusts debug-only buffer tracking to exclude WebAssembly targets.
>
> - Adds `not(target_family = "wasm")` to `#[cfg(all(debug_assertions, not(windows)))]` guards
> - Applies to `BUFFER_DATA` thread_local in `buffer.rs` and duplicate-pointer checks in `arraybuffer.rs` (including typed array slices and `Uint8ClampedSlice`)
> - Prevents wasm builds from using debug TLS-based pointer checks/panics
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ac6a276. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Chores**
  * Refined platform-specific compilation settings for WebAssembly builds to optimize build handling.

<sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app bot merged commit e55bc34 into main Dec 30, 2025
74 of 75 checks passed
@graphite-app graphite-app bot deleted the bisect/cfg-only branch December 30, 2025 04:55
@github-actions github-actions bot mentioned this pull request Dec 29, 2025
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.

1 participant