mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
http2: use original error for cancelling pending streams
Previously, if `session.destroy()` was called with an error object, the information contained in it would be discarded and a generic `ERR_HTTP2_STREAM_CANCEL` would be used for all pending streams. Instead, make the information from the original error object available. PR-URL: https://github.com/nodejs/node/pull/18988 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
2 files changed
+13
-3
No files matched your search
@@ -1129,6 +1129,11 @@ class Http2Session extends EventEmitter {
|
||||
|
||||
// Destroy any pending and open streams
|
||||
const cancel = new errors.Error('ERR_HTTP2_STREAM_CANCEL');
|
||||
if (error) {
|
||||
cancel.cause = error;
|
||||
if (typeof error.message === 'string')
|
||||
cancel.message += ` (caused by: ${error.message})`;
|
||||
}
|
||||
state.pendingStreams.forEach((stream) => stream.destroy(cancel));
|
||||
state.streams.forEach((stream) => stream.destroy(error));
|
||||
|
||||
|
||||
@@ -88,9 +88,14 @@ function runTest(test) {
|
||||
req.on('error', errorMustCall);
|
||||
} else {
|
||||
client.on('error', errorMustCall);
|
||||
req.on('error', common.expectsError({
|
||||
code: 'ERR_HTTP2_STREAM_CANCEL'
|
||||
}));
|
||||
req.on('error', (err) => {
|
||||
common.expectsError({
|
||||
code: 'ERR_HTTP2_STREAM_CANCEL'
|
||||
})(err);
|
||||
common.expectsError({
|
||||
code: 'ERR_HTTP2_ERROR'
|
||||
})(err.cause);
|
||||
});
|
||||
}
|
||||
|
||||
req.on('end', common.mustCall());
|
||||
|
||||
Reference in new issue
Block a user