Skip to content

Commit 4e19317

Browse files
committed
test: deflake test-buffer-large-size
1 parent 77f88b9 commit 4e19317

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/pummel/test-buffer-large-size.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --expose-gc
12
'use strict';
23
const common = require('../common');
34

@@ -25,9 +26,13 @@ const size = 2 ** 31;
2526
test('Buffer.toString with too long size', () => {
2627
try {
2728
assert.throws(() => SlowBuffer(size).toString('utf8'), stringTooLongError);
29+
globalThis.gc({ type: 'major' });
2830
assert.throws(() => Buffer.alloc(size).toString('utf8'), stringTooLongError);
31+
globalThis.gc({ type: 'major' });
2932
assert.throws(() => Buffer.allocUnsafe(size).toString('utf8'), stringTooLongError);
33+
globalThis.gc({ type: 'major' });
3034
assert.throws(() => Buffer.allocUnsafeSlow(size).toString('utf8'), stringTooLongError);
35+
globalThis.gc({ type: 'major' });
3136
} catch (e) {
3237
if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') {
3338
throw e;
@@ -42,6 +47,7 @@ test('Buffer.write with too long size', () => {
4247
const buf = Buffer.alloc(size);
4348
assert.strictEqual(buf.write('a', 2, kStringMaxLength), 1);
4449
assert.strictEqual(buf.write('a', 2, size), 1);
50+
globalThis.gc({ type: 'major' });
4551
} catch (e) {
4652
if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') {
4753
throw e;

0 commit comments

Comments
 (0)