Skip to content

node-api: reject detaching immutable arraybuffers - #67388

Open
fatihguzeldev wants to merge 1 commit into
nodejs:mainfrom
fatihguzeldev:napi-detach-immutable
Open

fatihguzeldev wants to merge 1 commit into
nodejs:mainfrom
fatihguzeldev:napi-detach-immutable

Conversation

@fatihguzeldev

Copy link
Copy Markdown
Contributor

napi_detach_arraybuffer() aborts when passed an immutable arraybuffer.
return napi_detachable_arraybuffer_expected instead.

Refs: #66346

return napi_detachable_arraybuffer_expected for immutable arraybuffers
instead of aborting when v8 rejects the detach operation.

Refs: nodejs#66346
Signed-off-by: Fatih GΓΌzel <fatihguzeldev@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/node-api

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. node-api Issues and PRs related to Node-API. labels Nov 10, 2026
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
βœ… Project coverage is 90.72%. Comparing base (2929073) to head (1bbb8f7).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/js_native_api_v8.cc 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67388      +/-   ##
==========================================
- Coverage   92.62%   90.72%   -1.91%     
==========================================
  Files         430      798     +368     
  Lines      196333   280076   +83743     
  Branches    29897    53886   +23989     
==========================================
+ Hits       181849   254089   +72240     
- Misses      14159    16276    +2117     
- Partials      325     9711    +9386     
Files with missing lines Coverage Ξ”
src/js_native_api_v8.cc 76.63% <0.00%> (ΓΈ)

... and 510 files with indirect coverage changes

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KevinEady

KevinEady commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Why does V8 consider an immutable ArrayBuffer to be detachable, i.e. it->IsDetachable() returns true for immutable ArrayBuffers? I feel like this would be an issue with V8's concept of "is detachable".

According to the proposal:

An immutable buffer cannot be detached, resized, or further transferred.

So, shouldn’t an immutable ArrayBuffer return false for an β€œis detachable” API check? Since it cannot be detached... πŸ€”

@legendecas

Copy link
Copy Markdown
Member

I agree, this sounds like should be fixed in V8.

@fatihguzeldev

Copy link
Copy Markdown
Contributor Author

i hadn't thought of it that way, but i think you guys are right. i'm still new around here. i'll see if i can fix this in v8.

@fatihguzeldev

Copy link
Copy Markdown
Contributor Author

i opened a fix in v8: https://chromium-review.googlesource.com/c/v8/v8/+/8829814

@jasnell

jasnell commented Nov 22, 2026

Copy link
Copy Markdown
Member

Once that lands, we'll need to make sure to follow up with a cherry-pick into our vendored v8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. node-api Issues and PRs related to Node-API.

Projects

Status: Need Triage

Development

Successfully merging this pull request may close these issues.

5 participants