test: deflake test-buffer-tostring-rangeerror - #65755
Open
christianaurichzm wants to merge 1 commit into
Open
Conversation
The test allocates a buffer one byte longer than MAX_STRING_LENGTH and
expects toString('utf8') to throw ERR_STRING_TOO_LONG. MAX_STRING_LENGTH
counts UTF-16 units rather than bytes, so that only holds if every byte
decodes to a single unit. For the two Buffer.allocUnsafe variants the
contents are whatever the allocator hands back, and a single multi-byte
UTF-8 sequence anywhere in the buffer decodes to fewer units than it
occupies bytes, bringing the result down to MAX_STRING_LENGTH or less
so that nothing is thrown.
This goes unnoticed when the allocator returns zeroed pages, which is
why the test passes elsewhere. The AIX builders expose non-zero
contents and fail with "Missing expected exception (Error)".
Refs: nodejs/reliability#1649
Signed-off-by: Christian Aurich <christian.aurichzm@gmail.com>
christianaurichzm
force-pushed
the
test-buffer-tostring-rangeerror
branch
from
September 3, 2026 05:42
c96a357 to
f06f11d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65755 +/- ##
==========================================
- Coverage 89.97% 89.95% -0.02%
==========================================
Files 757 757
Lines 258066 258080 +14
Branches 48926 48932 +6
==========================================
- Hits 232182 232163 -19
- Misses 16966 16974 +8
- Partials 8918 8943 +25 🚀 New features to boost your workflow:
|
panva
approved these changes
Sep 3, 2026
Collaborator
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.
parallel/test-buffer-tostring-rangeerrorhas been failing on the AIX 7.2 and AIX 7.3 builders with:The test allocates
MAX_STRING_LENGTH + 1bytes and expectstoString('utf8')to throwERR_STRING_TOO_LONG. However,MAX_STRING_LENGTHcounts UTF-16 units rather than bytes. WithBuffer.allocUnsafe()andBuffer.allocUnsafeSlow(), uninitialized contents may contain multi-byte UTF-8 sequences, making the decoded string short enough not to exceed the limit.Zero-filling the buffer makes every byte decode to one UTF-16 unit, so the test checks the intended boundary deterministically. The zero-filled allocation cases are unaffected.
Refs: nodejs/reliability#1648
Refs: nodejs/reliability#1649