diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-03-21 13:01:41 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-03-27 01:38:05 +0100 |
commit | d111d7b91c16ec420f231da4f6877a9b446de6d8 (patch) | |
tree | 0339334ba6ee37986d5ca982c76f3d8f6b9ce961 /lib | |
parent | cdfe47b323b8f8b495c23f65b6570021eea16239 (diff) | |
download | node-new-d111d7b91c16ec420f231da4f6877a9b446de6d8.tar.gz |
stream: give error message if `write()` cb called twice
Otherwise, this condition would result in an error that just reads
`cb is not a function`, and which additionally could have lost
stack trace context through a `process.nextTick()` call.
PR-URL: https://github.com/nodejs/node/pull/19510
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_stream_writable.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index df1d4076d0..d21daf0541 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -37,6 +37,7 @@ const { getHighWaterMark } = require('internal/streams/state'); const { ERR_INVALID_ARG_TYPE, ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK, ERR_STREAM_CANNOT_PIPE, ERR_STREAM_DESTROYED, ERR_STREAM_NULL_VALUES, @@ -449,6 +450,9 @@ function onwrite(stream, er) { var sync = state.sync; var cb = state.writecb; + if (typeof cb !== 'function') + throw new ERR_MULTIPLE_CALLBACK(); + onwriteStateUpdate(state); if (er) |