mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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>
26 lines
723 B
JavaScript
26 lines
723 B
JavaScript
// Flags: --expose-gc
|
|
'use strict';
|
|
|
|
// Test that 'close' emits once and not twice when `emitClose: true` is set.
|
|
// Refs: https://github.com/nodejs/node/issues/31366
|
|
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
const filepath = tmpdir.resolve('write_pos.txt');
|
|
|
|
const fileReadStream = fs.createReadStream(process.execPath);
|
|
const fileWriteStream = fs.createWriteStream(filepath, {
|
|
emitClose: true
|
|
});
|
|
|
|
fileReadStream.pipe(fileWriteStream);
|
|
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' });
|
|
}));
|