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 authored and RafaelGSS committed 2025-05-02 17:06:36 -03:00
1 parent da05addc5e
commit f2fd19e641
1 file changed
+6 -1
+6 -1
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' });
}));