Skip to content

fix(util-stream): warn when buffered readable encounters mixed Buffer/Uint8Array chunks#1881

Open
TrevorBurnham wants to merge 1 commit intosmithy-lang:mainfrom
TrevorBurnham:fix/buffered-readable-mixed-chunk-warning
Open

fix(util-stream): warn when buffered readable encounters mixed Buffer/Uint8Array chunks#1881
TrevorBurnham wants to merge 1 commit intosmithy-lang:mainfrom
TrevorBurnham:fix/buffered-readable-mixed-chunk-warning

Conversation

@TrevorBurnham
Copy link
Contributor

Issue #, if available:

Resolves #1553

Description of changes:

When a stream mixes Uint8Array and Buffer chunk types, createBufferedReadable flushes its internal buffer on every type switch regardless of size. This can produce undersized chunks that downstream consumers (like S3's chunked upload) reject with InvalidChunkSizeError, which is confusing when the user has explicitly set requestStreamBufferSize.

This change adds a logger.warn() when the buffering logic detects a switch between Buffer (mode 2) and Uint8Array (mode 1) chunks, in both the Node Readable and ReadableStream code paths. The warning explains the cause and tells the user to normalize their stream to a consistent chunk type.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@TrevorBurnham TrevorBurnham requested a review from a team as a code owner February 21, 2026 03:35
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.

createBufferedReadable fails to buffer properly if chunks are mixed Buffer/Uint8Array instances

1 participant