Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: deflake test-buffer-large-size-buffer-alloc
Use the error message as another condition to skip the test when the
buffer allocation fails.

Refs: 795dd8eb7988ae38553e
Refs: e9c6004a2d580008082b
  • Loading branch information
lpinca committed Jun 16, 2025
commit 8f1319a53ea487c1b3e2a2d1d6908018e47eaf34
18 changes: 14 additions & 4 deletions test/pummel/test-buffer-large-size-buffer-alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ common.skipIf32Bits();
const assert = require('node:assert');
const size = 2 ** 31;

let largeBuffer;

// Test Buffer.alloc with size larger than integer range
try {
assert.throws(() => Buffer.alloc(size).toString('utf8'), { code: 'ERR_STRING_TOO_LONG' });
largeBuffer = Buffer.alloc(size);
} catch (e) {
if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') {
throw e;
if (
e.code === 'ERR_MEMORY_ALLOCATION_FAILED' ||
/Array buffer allocation failed/.test(e.message)
) {
common.skip('insufficient space for Buffer.alloc');
}
common.skip('insufficient space for Buffer.alloc');

throw e;
}

assert.throws(() => largeBuffer.toString('utf8'), {
code: 'ERR_STRING_TOO_LONG',
});
Loading