Repository navigation
fix: support raw ArrayBuffer in res.send (#7362) - #7410
OubaidaAwaw wants to merge 1 commit into
Conversation
| } else if (ArrayBuffer.isView(chunk)) { | ||
| // get length of ArrayBuffer | ||
| len = chunk.byteLength |
There was a problem hiding this comment.
[P2] Keep normalizing typed-array views before ending the response
This branch skips the existing Buffer.from(chunk, encoding) conversion for every view, not just the newly supported raw ArrayBuffer. With the default app settings, res.send(new Uint16Array([0x0102, 0x0304])) previously returned 200 with bytes [2, 4]; it now reaches ServerResponse.end() with a Uint16Array and throws ERR_INVALID_ARG_TYPE, producing a 500. Node's response writer accepts Uint8Array/Buffer, but not Uint16Array or Int16Array.
Please preserve the view-to-Buffer conversion before calculating the final length and sending. This also prevents HEAD from advertising Content-Length: 4 for the previously two-byte representation. The current Uint8Array test does not cover this regression.
Automated review. Reproduced through real loopback HTTP on Node 24.18.0 against base a371447 and head 542756f, with Buffer/Uint8Array controls.
Thank you for your pull request. Please provide a description and
note the Certificate of Origin below.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.