fix: set { stream: true } when calling decoder.decode on multiple chunks - #11409
Conversation
🦋 Changeset detectedLatest commit: 57cdb28 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The linked MDN docs state that https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode#options |
|
Thanks for the feedback @benmccann! I'm unable to glean from the code what condition to check to know whether the loop is on the last chunk. |
{ stream: true } when calling decoder.decode on multiple chunks
|
I also don't see a way how we would know that it's the last chunk before receiving it with the empty value, at which point we don't need to call |
|
Perhaps add Tangential,
|
|
I think it's fine to just always use I asked ChatGPT and it basically concurs, FWIW.
It looks like there are other necessary conditions besides multi-byte characters — the body needs to be large enough that the string is chunked, and the server needs to chunk it in an inconvenient way (in the repro this happens non-deterministically, and I can't reproduce it locally at all which suggests it may be a quirk of Caddy. It would make sense to me that most servers would strive to avoid splitting characters like this, and if my admittedly incomplete understanding of string encoding is correct, all it takes is to ensure that each chunk length is a multiple of 4 bytes). So I'm not particularly surprised that this didn't surface sooner! |
|
Makes sense, thanks Rich!
Same here, as mentioned in #11044 (comment)
|
Fixes #11044
The bug
� will appear. refreshing fixes.
The reason
https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode#stream
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.