mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
fs: use finished over destroy w/ cb
destroy w/ is undocumented API which also will cause a race if the stream is already destroying and potentially invoking the callback too early and withou error. PR-URL: https://github.com/nodejs/node/pull/32809 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
This commit is contained in:
@@ -23,7 +23,7 @@ const {
|
||||
copyObject,
|
||||
getOptions,
|
||||
} = require('internal/fs/utils');
|
||||
const { Readable, Writable } = require('stream');
|
||||
const { Readable, Writable, finished } = require('stream');
|
||||
const { toPathIfFileURL } = require('internal/url');
|
||||
const kIoDone = Symbol('kIoDone');
|
||||
const kIsPerformingIO = Symbol('kIsPerformingIO');
|
||||
@@ -273,7 +273,8 @@ function closeFsStream(stream, cb, err) {
|
||||
}
|
||||
|
||||
ReadStream.prototype.close = function(cb) {
|
||||
this.destroy(null, cb);
|
||||
if (typeof cb === 'function') finished(this, cb);
|
||||
this.destroy();
|
||||
};
|
||||
|
||||
ObjectDefineProperty(ReadStream.prototype, 'pending', {
|
||||
|
||||
Reference in New Issue
Block a user