Skip to content

Copy ArrayBufferView bodies by their byte ranges - #1487

Open
xiehuanyi wants to merge 3 commits into
JakeChampion:mainfrom
xiehuanyi:fix/buffer-view-body-bytes
Open

xiehuanyi wants to merge 3 commits into
JakeChampion:mainfrom
xiehuanyi:fix/buffer-view-body-bytes

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 11, 2026 •

Copy link
Copy Markdown

DataView bodies currently clone the full backing buffer, ignoring the selected offset and length. Wide typed-array bodies also lose bytes during .text() conversion: a Uint16Array containing the bytes of Hello World! becomes HloWrd.

Copy ArrayBufferView bodies into an ArrayBuffer using their byte offset and length, as required by BodyInit extraction. Use actual view type checks so an ordinary ArrayBuffer with a custom buffer property still copies its own bytes. Retain native typed-array slicing before extracting the clone’s byte range, so view expando properties are ignored and shared Buffer-style slices still produce the correct ArrayBuffer. Preserve the DataView-to-Blob workaround. Add Request and Response consumption cases for DataView/Uint8Array subranges and Uint16Array bodies, and verify that .arrayBuffer() returns an ArrayBuffer.

Validation: the original regressions produce eight failures before the change in Chrome. The ordinary-ArrayBuffer regression also fails before the actual view type check. make passes lint and builds; the complete npm test passes after the change in Chrome and Firefox, both in the page and Web Worker suites (675 successful cases per suite, with browser feature skips). git diff --check passes. Firefox needed a home-visible temporary profile directory in this environment; IE/Edge were not exercised.

AI disclosure: OpenAI Codex assisted with investigation, implementation, and validation.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 07:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

2 participants