Skip to content

fix(res.send): preserve DataView byte ranges - #7511

Open
nikhiljangid120 wants to merge 1 commit into
expressjs:masterfrom
nikhiljangid120:fix/send-dataview-bytes
Open

nikhiljangid120 wants to merge 1 commit into
expressjs:masterfrom
nikhiljangid120:fix/send-dataview-bytes

Conversation

@nikhiljangid120

Copy link
Copy Markdown

Fixes #7510.

res.send(DataView) currently returns an empty body because Buffer.from(dataView) discards its contents. Convert only DataViews from their backing buffer, byte offset, and byte length. node:util.types.isDataView also recognizes cross-realm views.

This revisits #7433, which its author closed without merging. The fix preserves the existing Buffer, Uint8Array, and non-byte typed-array paths, including the Uint16Array compatibility concern discussed in that review. Bare ArrayBuffer support (#7362) is outside this change.

Verification on Node 24.14.1 / Linux:

  • Added 11 regression cases: full, sliced, empty, and cross-realm views with ETags enabled/disabled; explicit Content-Type; HEAD; existing Uint16Array conversion.
  • Eight new cases fail on the original implementation and pass with the fix.
  • npm run test-ci: 1,272 passing.
  • npm run lint: passed.
  • No dependencies, manifests, or lockfiles changed.

AI assistance was used for investigation, implementation, and local validation.

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.

res.send(DataView) silently drops the view’s bytes

1 participant