Repository navigation
Writer cannot cope with ArrayBuffer #43433
Copy link
Copy link
Closed
Labels
help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.web streamsIssues and PRs related to the Web Streams API.Issues and PRs related to the Web Streams API.web-standardsIssues and PRs related to web-platform APIs and standards compliance.Issues and PRs related to web-platform APIs and standards compliance.
Description
Version
v19.0.0-pre
Platform
Darwin
Subsystem
web/streams
What steps will reproduce the bug?
Try the following code both on chrome & nodejs:
const str = "H4sIAAAAAAAAE0vLzwcAIWVzjAMAAAA=";
const buf = Uint8Array.from(atob(str), c => c.charCodeAt(0));
const ds = new DecompressionStream("gzip");
const writer = ds.writable.getWriter();
writer.write(buf.buffer);
writer.close();
await new Response(ds.readable).arrayBuffer();How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
node:internal/errors:477
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of ArrayBuffer
at new NodeError (node:internal/errors:388:5)
at _write (node:internal/streams/writable:315:13)
at Writable.write (node:internal/streams/writable:337:10)
at Object.write (node:internal/webstreams/adapters:166:63)
at ensureIsPromise (node:internal/webstreams/util:172:19)
at writableStreamDefaultControllerProcessWrite (node:internal/webstreams/writablestream:1091:5)
at writableStreamDefaultControllerAdvanceQueueIfNeeded (node:internal/webstreams/writablestream:1206:5)
at node:internal/webstreams/writablestream:1278:7 {
code: 'ERR_INVALID_ARG_TYPE'
}
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.web streamsIssues and PRs related to the Web Streams API.Issues and PRs related to the Web Streams API.web-standardsIssues and PRs related to web-platform APIs and standards compliance.Issues and PRs related to web-platform APIs and standards compliance.
Activity
debadree25 commentedon Dec 21, 2022
For this issue is the function write supposed to work on Buffer | Uint8Array | ArrayBuffer?
cc @ronag @VoltrexKeyva
MarybethGasman commentedon Feb 1, 2023
According to the documentation, the function write is not supposed to work on <ArrayBuffer> in node.(It works in chrome.)
Using <Uint8Array> is fine.
MrJithil commentedon Oct 9, 2023
So, this can be closed?
panva commentedon Nov 9, 2023
No, CompressionStream and DecompressionStream are supposed to handle
BufferSource, that means, as per how this is done WebCryptoAPI -<ArrayBuffer> | <TypedArray> | <DataView> | <Buffer>should all be valid chunks.The WPTs for this will soon be enabled #50631.
suuuuuuminnnnnn commentedon Feb 21, 2026
I'd like to work on this issue if no one is currently working on it.
I can investigate the
BufferSourcehandling inCompressionStream/DecompressionStreamand put together a PR with a regression test.stream: accept ArrayBuffer in CompressionStream and DecompressionStream
stream: accept ArrayBuffer in CompressionStream and DecompressionStream
stream: accept ArrayBuffer in CompressionStream and DecompressionStream
stream: accept ArrayBuffer in CompressionStream and DecompressionStream
stream: accept ArrayBuffer in CompressionStream and DecompressionStream
stream: accept ArrayBuffer in CompressionStream and DecompressionStream
stream: accept ArrayBuffer in CompressionStream and DecompressionStream