diff options
author | Robert Nagy <ronagy@icloud.com> | 2019-08-24 16:33:46 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-09-30 10:56:29 -0700 |
commit | f663b31cc2aecd585e73430504f3d7f5252851ca (patch) | |
tree | b727bf953711f9f83fa9b7dca13e30f07d17d694 /test/parallel/test-stream-writable-destroy.js | |
parent | 634a9a97f4b380390352543452aed6c7c9defcb4 (diff) | |
download | android-node-v8-f663b31cc2aecd585e73430504f3d7f5252851ca.tar.gz android-node-v8-f663b31cc2aecd585e73430504f3d7f5252851ca.tar.bz2 android-node-v8-f663b31cc2aecd585e73430504f3d7f5252851ca.zip |
stream: always invoke callback before emitting error
Ensure the callback is always invoked before emitting
the error in both sync and async case.
PR-URL: https://github.com/nodejs/node/pull/29293
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-stream-writable-destroy.js')
-rw-r--r-- | test/parallel/test-stream-writable-destroy.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/parallel/test-stream-writable-destroy.js b/test/parallel/test-stream-writable-destroy.js index ac107ecbb7..c4a96788ab 100644 --- a/test/parallel/test-stream-writable-destroy.js +++ b/test/parallel/test-stream-writable-destroy.js @@ -18,6 +18,20 @@ const assert = require('assert'); { const write = new Writable({ + write(chunk, enc, cb) { + this.destroy(new Error('asd')); + cb(); + } + }); + + write.on('error', common.mustCall()); + write.on('finish', common.mustNotCall()); + write.end('asd'); + assert.strictEqual(write.destroyed, true); +} + +{ + const write = new Writable({ write(chunk, enc, cb) { cb(); } }); |