diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-04-01 21:56:11 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-04-12 16:39:36 +0300 |
commit | 93967d00e9feb944b1ec907dabaaf32f243e5806 (patch) | |
tree | ba719457a670a5e3a4fc25f3544341e33198c26d /lib/internal/stream_base_commons.js | |
parent | bb6de0d4a844959fddd00e28d190d3d3ccbef8c9 (diff) |
net,http2: merge write error handling & property names
Merge error handling for `net.Socket`s and `Http2Stream`s,
and align the callback property names as `callback`.
Refs: https://github.com/nodejs/node/issues/19060
PR-URL: https://github.com/nodejs/node/pull/19734
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib/internal/stream_base_commons.js')
-rw-r--r-- | lib/internal/stream_base_commons.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/internal/stream_base_commons.js b/lib/internal/stream_base_commons.js index d902a501524..b252b1d8ff7 100644 --- a/lib/internal/stream_base_commons.js +++ b/lib/internal/stream_base_commons.js @@ -61,15 +61,24 @@ function writevGeneric(self, req, data, cb) { // Retain chunks if (err === 0) req._chunks = chunks; - if (err) - return self.destroy(errnoException(err, 'write', req.error), cb); + afterWriteDispatched(self, req, err, cb); } function writeGeneric(self, req, data, encoding, cb) { var err = handleWriteReq(req, data, encoding); - if (err) + afterWriteDispatched(self, req, err, cb); +} + +function afterWriteDispatched(self, req, err, cb) { + if (err !== 0) return self.destroy(errnoException(err, 'write', req.error), cb); + + if (!req.async) { + cb(); + } else { + req.callback = cb; + } } module.exports = { |