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 7d9eb17

Browse filesBrowse files
himself65targos
authored andcommitted
http2: destroy when settingsFn throws an error
http2.connect should call destroy when init fails. PR-URL: #28908 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent f4abf17 commit 7d9eb17
Copy full SHA for 7d9eb17

File tree

Expand file treeCollapse file tree

2 files changed

+21
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+21
-1
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
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,13 @@ class Http2Session extends EventEmitter {
976976
if (socket.connecting) {
977977
const connectEvent =
978978
socket instanceof tls.TLSSocket ? 'secureConnect' : 'connect';
979-
socket.once(connectEvent, setupFn);
979+
socket.once(connectEvent, () => {
980+
try {
981+
setupFn();
982+
} catch (error) {
983+
socket.destroy(error);
984+
}
985+
});
980986
} else {
981987
setupFn();
982988
}
Collapse file

‎test/parallel/test-http2-connect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-connect.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ const { connect: netConnect } = require('net');
6969
connect(authority).on('error', () => {});
7070
}
7171

72+
// Check for error for init settings error
73+
{
74+
createServer(function() {
75+
connect(`http://localhost:${this.address().port}`, {
76+
settings: {
77+
maxFrameSize: 1 // An incorrect settings
78+
}
79+
}).on('error', expectsError({
80+
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
81+
type: RangeError
82+
}));
83+
});
84+
}
85+
7286
// Check for error for an invalid protocol (not http or https)
7387
{
7488
const authority = 'ssh://localhost';

0 commit comments

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