Skip to content

test: deflake test-buffer-tostring-rangeerror - #65755

Open
christianaurichzm wants to merge 1 commit into
nodejs:mainfrom
christianaurichzm:test-buffer-tostring-rangeerror
Open

test: deflake test-buffer-tostring-rangeerror#65755
christianaurichzm wants to merge 1 commit into
nodejs:mainfrom
christianaurichzm:test-buffer-tostring-rangeerror

Conversation

@christianaurichzm

Copy link
Copy Markdown
Contributor

parallel/test-buffer-tostring-rangeerror has been failing on the AIX 7.2 and AIX 7.3 builders with:

AssertionError [ERR_ASSERTION]: Missing expected exception (Error).

The test allocates MAX_STRING_LENGTH + 1 bytes and expects toString('utf8') to throw ERR_STRING_TOO_LONG. However, MAX_STRING_LENGTH counts UTF-16 units rather than bytes. With Buffer.allocUnsafe() and
Buffer.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

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure. labels Sep 3, 2026
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
christianaurichzm force-pushed the test-buffer-tostring-rangeerror branch from c96a357 to f06f11d Compare September 3, 2026 05:42
@christianaurichzm christianaurichzm changed the title test: zero-fill buffers before the string length limit check test: deflake test-buffer-tostring-rangeerror Sep 3, 2026
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.95%. Comparing base (b53ddc0) to head (f06f11d).
⚠️ Report is 11 commits behind head on main.

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     

see 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@panva panva added the flaky-test Issues and PRs involving tests that fail intermittently in CI. label Sep 3, 2026
@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. labels Sep 3, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. flaky-test Issues and PRs involving tests that fail intermittently in CI. needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants