summaryrefslogtreecommitdiff
path: root/lib/_stream_writable.js
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-08-05 16:07:49 +0200
committerMatteo Collina <hello@matteocollina.com>2019-09-20 11:22:31 +0200
commitba3be578d8bbca1bafc391984b0e6f037507dcbc (patch)
treefa500fb8d363ad57eae865b9a84127931632f3d8 /lib/_stream_writable.js
parentdc7c7b83bedb1723344f3bf2e31bb666675e5fec (diff)
downloadandroid-node-v8-ba3be578d8bbca1bafc391984b0e6f037507dcbc.tar.gz
android-node-v8-ba3be578d8bbca1bafc391984b0e6f037507dcbc.tar.bz2
android-node-v8-ba3be578d8bbca1bafc391984b0e6f037507dcbc.zip
stream: don't emit finish on error
After 'error' only 'close' should be emitted. PR-URL: https://github.com/nodejs/node/pull/28979 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/_stream_writable.js')
-rw-r--r--lib/_stream_writable.js10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
index e212881c4a..4cb3be5c00 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -437,19 +437,12 @@ function onwriteError(stream, state, sync, er, cb) {
// Defer the callback if we are being called synchronously
// to avoid piling up things on the stack
process.nextTick(cb, er);
- // This can emit finish, and it will always happen
- // after error
- process.nextTick(finishMaybe, stream, state);
- errorOrDestroy(stream, er);
} else {
// The caller expect this to happen before if
// it is async
cb(er);
- errorOrDestroy(stream, er);
- // This can emit finish, but finish must
- // always follow error
- finishMaybe(stream, state);
}
+ errorOrDestroy(stream, er);
}
function onwrite(stream, er) {
@@ -618,6 +611,7 @@ Object.defineProperty(Writable.prototype, 'writableLength', {
function needFinish(state) {
return (state.ending &&
state.length === 0 &&
+ !state.errorEmitted &&
state.bufferedRequest === null &&
!state.finished &&
!state.writing);