Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa0fca9

Browse filesBrowse files
committed
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: #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>
1 parent a455006 commit aa0fca9
Copy full SHA for aa0fca9

File tree

Expand file treeCollapse file tree

2 files changed

+13
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,11 @@ class Http2Session extends EventEmitter {
11291129

11301130
// Destroy any pending and open streams
11311131
const cancel = new errors.Error('ERR_HTTP2_STREAM_CANCEL');
1132+
if (error) {
1133+
cancel.cause = error;
1134+
if (typeof error.message === 'string')
1135+
cancel.message += ` (caused by: ${error.message})`;
1136+
}
11321137
state.pendingStreams.forEach((stream) => stream.destroy(cancel));
11331138
state.streams.forEach((stream) => stream.destroy(error));
11341139

Collapse file

‎test/parallel/test-http2-client-onconnect-errors.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-client-onconnect-errors.js
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,14 @@ function runTest(test) {
8888
req.on('error', errorMustCall);
8989
} else {
9090
client.on('error', errorMustCall);
91-
req.on('error', common.expectsError({
92-
code: 'ERR_HTTP2_STREAM_CANCEL'
93-
}));
91+
req.on('error', (err) => {
92+
common.expectsError({
93+
code: 'ERR_HTTP2_STREAM_CANCEL'
94+
})(err);
95+
common.expectsError({
96+
code: 'ERR_HTTP2_ERROR'
97+
})(err.cause);
98+
});
9499
}
95100

96101
req.on('end', common.mustCall());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.