MBS-14308: Fix readUInt32LE RangeError in the template renderer#3741
Open
mwiencek wants to merge 1 commit into
Open
MBS-14308: Fix readUInt32LE RangeError in the template renderer#3741mwiencek wants to merge 1 commit into
readUInt32LE RangeError in the template renderer#3741mwiencek wants to merge 1 commit into
Conversation
This commit was written with the help of kiro-cli, which uses a variety of models underneath. Here's what it had to say, which I think is useful: "The bug is clear. When a new data chunk arrives and recvBuffer is null, the code assumes the first 4 bytes are always present in that chunk to read the UInt32LE length prefix. But TCP is a stream — a chunk can arrive with fewer than 4 bytes, causing readUInt32LE(0) to throw RangeError: Attempt to access memory outside buffer bounds." Initially, the model suggested a different fix which added additional allocations, and after some back-and-forth, I got it to produce some code which reads the header byte-by-byte. I wrote the comments and chose the variable name. While I'm not sure how to reliably trigger the bug through normal browsing, I had the AI generate a script which triggers the issue, which helped me verify that the fix worked.
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.
Problem
MBS-14308
Solution
This commit was written with the help of kiro-cli, which uses a variety of models underneath. Here's what it had to say, which I think is useful:
"The bug is clear. When a new data chunk arrives and recvBuffer is null, the code assumes the first 4 bytes are always present in that chunk to read the UInt32LE length prefix. But TCP is a stream — a chunk can arrive with fewer than 4 bytes, causing readUInt32LE(0) to throw RangeError: Attempt to access memory outside buffer bounds."
Initially, the model suggested a different fix which added additional allocations, and after some back-and-forth, I got it to produce some code which reads the header byte-by-byte. I wrote the comments and chose the variable name.
AI usage
See above.
Testing
While I'm not sure how to reliably trigger the bug through normal browsing, I had the AI generate a script which triggers the issue, which helped me verify that the fix worked. Didn't notice any other change in browsing various pages. I also added logging on both the Perl & JS sides to verify that the number of bytes sent by Perl still matches the
expectedByteson the JS side.