Skip to content

fix(runtime): recognize Buffers in typed-array predicates (#11239) - #11243

Merged
proggeramlug merged 2 commits into
mainfrom
fix/11239-buffer-view-predicates
Sep 24, 2026
Merged

proggeramlug merged 2 commits into
mainfrom
fix/11239-buffer-view-predicates

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #11239.

Node Buffers now return true from ArrayBuffer.isView, util.types.isArrayBufferView, util.types.isUint8Array, and util.types.isTypedArray, including extracted predicate calls. This restores the view check used by bson when accepting Buffer spans as UUID bytes.

The util typed-array classifier and ArrayBuffer.isView thunk reuse the existing Buffer-backed typed-array brand helper. ArrayBuffer, SharedArrayBuffer, DataView, and crypto key objects keep their distinct brands.

Validation:

  • The new runtime Buffer regression fails before the fix and passes afterward; backing-brand controls pass, including secret, asymmetric, and crypto keys.
  • Seventeen existing Buffer/view runtime tests pass.
  • Fresh perry-dev compiler plus runtime/stdlib archives; six native fixtures match Node 26.5.1 byte-for-byte: the new Buffer regression, typed arrays, typed-array prototype methods, generic annotations, DataView operations, and DataView backing aliasing.
  • Formatting, whitespace, file-size, Node-version consistency, test-registration, and address-classification checks pass.
  • Native comparisons use PERRY_NO_AUTO_OPTIMIZE=1; the full parity suite, auto-optimize lane, and live MongoDB integration were not run.

Checked GitHub PRs, local worktrees, and worktrees on root@perrymaster.skelpo.net before taking the issue; no competing fix was found. No version bump.

Summary by CodeRabbit

  • Bug Fixes
    • Buffer-backed typed arrays are now correctly recognized by ArrayBuffer.isView and related type checks, including when those checks are called through extracted aliases.
    • Detection now covers allocated Buffers and subarrays, including views over shared backing spans.
    • Raw ArrayBuffers, shared ArrayBuffers, DataViews, and crypto key backing data continue to be distinguished from typed-array views.
    • Added regression coverage for view detection and byte-length checks used during BSON UUID decoding.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 9dff63d1-4a33-466b-acb1-a1cc81b47f8f

📥 Commits

Reviewing files that changed from the base of the PR and between 5480f85 and 84e6c2b.

📒 Files selected for processing (4)
  • changelog.d/11243-buffer-view-predicates.md
  • crates/perry-runtime/src/object/global_this/typed_array.rs
  • crates/perry-runtime/src/object/util_types.rs
  • test-files/test_gap_11239_buffer_view_predicates.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

Runtime view predicates now recognize Buffer-backed typed arrays. The changes also add runtime assertions and a diagnostic test script for Buffer variants, typed arrays, and other backing types.

Changes

Buffer view predicates

Layer / File(s) Summary
Update and validate view predicates
crates/perry-runtime/src/object/global_this/typed_array.rs, crates/perry-runtime/src/object/util_types.rs, test-files/test_gap_11239_buffer_view_predicates.ts, changelog.d/11243-buffer-view-predicates.md
The runtime view checks use typed-array backing recognition. Runtime tests assert results for Buffer and marked backing types. The diagnostic script probes Buffer variants, typed arrays, and non-view values. The changelog records the change.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 84e6c

The Buffer predicate fix appears ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #11239 requires Buffer recognition by ArrayBuffer.isView, util.types.isArrayBufferView, and util.types.isUint8Array, including extracted calls and Buffer variants. The PR updates `jsvalue_…
Out of Scope Changes check ✅ Passed The changed runtime code implements the Buffer predicate fix from #11239. The Rust tests protect the required predicate and brand behavior. The TypeScript regression test covers the reported reproduct…
Title check ✅ Passed The title clearly identifies the main runtime change: recognizing Buffers in typed-array predicates.
Description check ✅ Passed The description provides a clear summary, links the related issue, describes implementation changes, documents validation results, and states which test suites were not run. It does not use the templa…
Full details: Docstring Coverage

Explanation

Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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.

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.

ArrayBuffer.isView / util.types.isArrayBufferView / isUint8Array return false for a Node Buffer (breaks bson UUID decode in mongodb)

1 participant