You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when buffering a stream, createBufferedReadable treats Uint8Array and Buffer chunks differently. Switching from one to the other inside a stream makes it flush its buffer - which can lead to an InvalidChunkSizeError when this function is used by S3Client. I'm not sure if mixing both Buffer and Uint8Array chunks in a same stream is "legal" or not, but it's an easy mistake to do if not, especially since on NodeJS Buffer is a base of Uint8Array (so Typescript won't complain if you mix them up).
Minimal reproducer:
import*asstreamsfrom"node:stream";import{PutObjectCommand,S3Client}from"@aws-sdk/client-s3";asyncfunctionmain(){constclient=newS3Client({requestStreamBufferSize: 32*1024});asyncfunction*mixedData(): AsyncIterable<Uint8Array>{yieldnewUint8Array(2000);// too small chunk, should get buffered with the following oneyieldBuffer.alloc(128_000);}// Triggers an InvalidChunkSizeErrorawaitclient.send(newPutObjectCommand({Bucket: "test-bucket",Key: "test",ContentLength: 130_000,Body: streams.Readable.from(mixedData()),}));}main();