diff options
author | Robert Nagy <ronagy@icloud.com> | 2020-01-16 20:42:54 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-01-20 03:43:42 +0300 |
commit | 7d5a86cc05f3b8782b37c7ed438b3e994f6bd713 (patch) | |
tree | 9428cacaeb96ef0d6dfaa70fa4e3b452b42d1671 /lib/internal/fs | |
parent | 57bd715d527aba8dae56b975056961b0e429e91e (diff) |
fs: do not emit 'close' twice if emitClose enabled
fs streams have some backwards compat behavior that does not
behave well if emitClose: true is passed in options. This
fixes this edge case until the backwards compat is removed.
PR-URL: https://github.com/nodejs/node/pull/31383
Fixes: https://github.com/nodejs/node/issues/31366
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/fs')
-rw-r--r-- | lib/internal/fs/streams.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index d1603f6a024..561216c353c 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -272,7 +272,8 @@ function closeFsStream(stream, cb, err) { er = er || err; cb(er); stream.closed = true; - if (!er) + const s = stream._writableState || stream._readableState; + if (!er && !s.emitClose) stream.emit('close'); }); |