0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-fs-read-stream-double-close.js
Matteo Collina e5c290bed9 fs: refactor close to use destroy
Refactor close() to use destroy() and not vice versa in ReadStream.
Avoid races between WriteStream.close and WriteStream.write, by aliasing
close to end().

Fixes: https://github.com/nodejs/node/issues/2006
PR-URL: https://github.com/nodejs/node/pull/15407
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-09-21 09:09:05 +02:00

20 lines
385 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
{
const s = fs.createReadStream(__filename);
s.close(common.mustCall());
s.close(common.mustCall());
}
{
const s = fs.createReadStream(__filename);
// this is a private API, but it is worth esting. close calls this
s.destroy(null, common.mustCall());
s.destroy(null, common.mustCall());
}