test: force GC in test-file-write-stream4

Reduce `test/parallel/test-file-write-stream4.js` flakiness.

Refs: https://github.com/nodejs/node/pull/57927
PR-URL: https://github.com/nodejs/node/pull/57930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
Luigi Pinca 2025-04-20 20:29:12 +02:00 committed by Marco Ippolito
parent da6a13c338
commit 275ea8e7ef
No known key found for this signature in database
GPG Key ID: 27F5E38D5B0A215F

View File

@ -1,3 +1,4 @@
// Flags: --expose-gc
'use strict';
// Test that 'close' emits once and not twice when `emitClose: true` is set.
@ -17,4 +18,8 @@ const fileWriteStream = fs.createWriteStream(filepath, {
});
fileReadStream.pipe(fileWriteStream);
fileWriteStream.on('close', common.mustCall());
fileWriteStream.on('close', common.mustCall(() => {
// TODO(lpinca): Remove the forced GC when
// https://github.com/nodejs/node/issues/54918 is fixed.
globalThis.gc({ type: 'major' });
}));