Skip to content

Commit 39caa6d

Browse files
JacksonTianaddaleax
authored andcommitted
fs: use _final() for fs.WriteStream
use _final() method instead of once 'finish' event. PR-URL: #20562 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ccf69dd commit 39caa6d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/fs.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2212,17 +2212,17 @@ function WriteStream(path, options) {
22122212

22132213
if (typeof this.fd !== 'number')
22142214
this.open();
2215-
2216-
// dispose on finish.
2217-
this.once('finish', function() {
2218-
if (this.autoClose) {
2219-
this.destroy();
2220-
}
2221-
});
22222215
}
22232216

22242217
fs.FileWriteStream = fs.WriteStream; // support the legacy name
22252218

2219+
WriteStream.prototype._final = function(callback) {
2220+
if (this.autoClose) {
2221+
this.destroy();
2222+
}
2223+
2224+
callback();
2225+
};
22262226

22272227
WriteStream.prototype.open = function() {
22282228
fs.open(this.path, this.flags, this.mode, (er, fd) => {

0 commit comments

Comments
 (0)