mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
e5c290bed9
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>
20 lines
385 B
JavaScript
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());
|
|
}
|