diff options
author | Ouyang Yadong <oyydoibh@gmail.com> | 2018-11-18 14:56:02 +0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-11-24 23:46:02 -0800 |
commit | 9389b464eaea7e74cf60c1d81c7bf1efda4e8897 (patch) | |
tree | 428270cbb451f01573c2cb57cfb8e8b8acdb1a02 /lib/net.js | |
parent | 8c0aa84f854d29ef44485d52c8bddba7a3ce77d0 (diff) | |
download | android-node-v8-9389b464eaea7e74cf60c1d81c7bf1efda4e8897.tar.gz android-node-v8-9389b464eaea7e74cf60c1d81c7bf1efda4e8897.tar.bz2 android-node-v8-9389b464eaea7e74cf60c1d81c7bf1efda4e8897.zip |
net: emit "write after end" errors in the next tick
This commit makes those errors caused by calling
`net.Socket.write()` after sockets ending be emitted in the next
tick.
PR-URL: https://github.com/nodejs/node/pull/24457
Fixes: https://github.com/nodejs/node/issues/24111
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/net.js')
-rw-r--r-- | lib/net.js | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/net.js b/lib/net.js index 25767b2574..ba7c3eb6da 100644 --- a/lib/net.js +++ b/lib/net.js @@ -401,8 +401,7 @@ function writeAfterFIN(chunk, encoding, cb) { // eslint-disable-next-line no-restricted-syntax var er = new Error('This socket has been ended by the other party'); er.code = 'EPIPE'; - // TODO: defer error events consistently everywhere, not just the cb - this.emit('error', er); + process.nextTick(emitErrorNT, this, er); if (typeof cb === 'function') { defaultTriggerAsyncIdScope(this[async_id_symbol], process.nextTick, cb, er); } |