diff options
author | 陈刚 <chengang07@meituan.com> | 2018-01-16 12:17:58 +0800 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2018-01-30 15:47:36 +0100 |
commit | c7ca07ab50bdfa29e43bb6d556544a298deeb300 (patch) | |
tree | 08689842603438c701abe40c5c751efeb3778bdf /lib/_stream_writable.js | |
parent | 49b3798f816fafe6af9a6de3303f6adc77d53259 (diff) | |
download | android-node-v8-c7ca07ab50bdfa29e43bb6d556544a298deeb300.tar.gz android-node-v8-c7ca07ab50bdfa29e43bb6d556544a298deeb300.tar.bz2 android-node-v8-c7ca07ab50bdfa29e43bb6d556544a298deeb300.zip |
stream: avoid writeAfterEnd() while ending
Calling `writable.end()` will probably synchronously call
`writable.write()`, in such a situation the `state.ended`
is false and `writable.write()` doesn't trigger `writeAfterEnd()`.
PR-URL: https://github.com/nodejs/node/pull/18170
Reviewed-By: Anna Henningsen <anna@addaleax.net>
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.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index de96a90255..154c87bf5c 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -273,7 +273,7 @@ Writable.prototype.write = function(chunk, encoding, cb) { if (typeof cb !== 'function') cb = nop; - if (state.ended) + if (state.ending) writeAfterEnd(this, cb); else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; |