Skip to content
Permalink
Browse files

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>
  • Loading branch information...
Himself65 authored and targos committed Jul 31, 2019
1 parent f4abf17 commit 7d9eb17d30112b362567ea079323e557902ba8ec
Showing with 21 additions and 1 deletion.
  1. +7 −1 lib/internal/http2/core.js
  2. +14 −0 test/parallel/test-http2-connect.js
@@ -976,7 +976,13 @@ class Http2Session extends EventEmitter {
if (socket.connecting) {
const connectEvent =
socket instanceof tls.TLSSocket ? 'secureConnect' : 'connect';
socket.once(connectEvent, setupFn);
socket.once(connectEvent, () => {
try {
setupFn();
} catch (error) {
socket.destroy(error);
}
});
} else {
setupFn();
}
@@ -69,6 +69,20 @@ const { connect: netConnect } = require('net');
connect(authority).on('error', () => {});
}

// Check for error for init settings error
{
createServer(function() {
connect(`http://localhost:${this.address().port}`, {
settings: {
maxFrameSize: 1 // An incorrect settings
}
}).on('error', expectsError({
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
type: RangeError
}));
});
}

// Check for error for an invalid protocol (not http or https)
{
const authority = 'ssh://localhost';

0 comments on commit 7d9eb17

Please sign in to comment.
You can’t perform that action at this time.