fix: compression handling of string streams#313
Merged
Conversation
Signed-off-by: Rich Ellis <ricellis@users.noreply.github.com>
a2a7469 to
15f6f30
Compare
pyrooka
approved these changes
Feb 4, 2026
Member
pyrooka
left a comment
There was a problem hiding this comment.
Wow, looks good thanks a lot for fixing this! I'm surprised that we didn't check the actual value in this scenario thus we had an incorrect code for years. Nice catch!
Happy for any feedback on a nicer way to do this than join.
I've no better idea than this.
However, it wasn't clear whether streamToPromise was considered API and might be used by external callers so I tried for a fix that didn't change the contract of that function at all.
AFAIK, we don't use it anywhere else but I'm also unsure about the external usage of this function. I agree with you, let's keep it for now. It shouldn't hurt us.
ibm-devx-sdk
pushed a commit
that referenced
this pull request
Feb 4, 2026
## [5.4.6](v5.4.5...v5.4.6) (2026-02-04) ### Bug Fixes * compression handling of string streams ([#313](#313)) ([b05f1aa](b05f1aa))
|
🎉 This PR is included in version 5.4.6 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
npm testpasses (tip:npm run lint-fixcan correct most style issues)There is a bug where a stream of
stringchunks does not get correctly compressed.The reason is that
streamToPromisecan return either aBufferor an array of string chunks.For the string array stream case
request-wrapper, forstreamDatathat isn'tBuffer,request-wrappercallsBuffer.from(streamData)for the array, but that doesn't provide the content of the stream becauseBuffer.from(array)expects an array of utf8 bytes, not an arraystring.I added a new test assertion to
gzipRequestBody › should compress stream data into a bufferto demonstrate this:This assertion passes correctly when request wrapper is changed to call
Buffer.from(streamData.join('')to convert the array of strings into a single string suitable forBuffer.from(string).Happy for any feedback on a nicer way to do this than
join.As far as I could see
gzipSyncrequires aBufferand this is the only placestreamToPromiseis called in the core so it might be better to remove this ternary andstreamToPromiseentirely and just callbuffer(stream)fromstream/consumers. However, it wasn't clear whetherstreamToPromisewas considered API and might be used by external callers so I tried for a fix that didn't change the contract of that function at all.