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 /test | |
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 'test')
-rw-r--r-- | test/parallel/test-stream-writable-write-writev-finish.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-stream-writable-write-writev-finish.js b/test/parallel/test-stream-writable-write-writev-finish.js index c4aaa36606..c0bb60f925 100644 --- a/test/parallel/test-stream-writable-write-writev-finish.js +++ b/test/parallel/test-stream-writable-write-writev-finish.js @@ -154,3 +154,27 @@ const stream = require('stream'); }; rs.pipe(ws); } + +{ + const w = new stream.Writable(); + w._write = (chunk, encoding, cb) => { + process.nextTick(cb); + }; + w.on('error', common.mustCall()); + w.on('prefinish', () => { + w.write("shouldn't write in prefinish listener"); + }); + w.end(); +} + +{ + const w = new stream.Writable(); + w._write = (chunk, encoding, cb) => { + process.nextTick(cb); + }; + w.on('error', common.mustCall()); + w.on('finish', () => { + w.write("should't write in finish listener"); + }); + w.end(); +} |