-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v12.x] tls: reset secureConnecting on client socket #34859
Conversation
729799d
to
c9bd1a7
Compare
55fe022
to
65b7bf4
Compare
Friendly ping :) Can this be addressed quick please? Or is there some extra work to do? |
secureConnecting is never set to false on client TLS sockets. So if Http2Session constructor (in lib/internal/http2/core.js) is called after secureConnect is emitted, then it will wrongly wait for a secureConnect event. This fix sets secureConnecting to false when a client TLS socket has connected. PR-URL: nodejs#33209 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
@szmarczak CI wasn’t passing here, but failing with what looked like related failures. I don’t necessarily have the time to look into those, so feel free to take over :) I’ve rebased and kick off another CI, let’s see how that goes. |
6bd69b8
to
6ff8562
Compare
It seems the session is destroyed before calling diff --git a/test/parallel/test-http2-connect.js b/test/parallel/test-http2-connect.js
index 9ee2e4347f..7267956222 100644
--- a/test/parallel/test-http2-connect.js
+++ b/test/parallel/test-http2-connect.js
@@ -90,7 +90,7 @@ const { connect: tlsConnect } = require('tls');
};
const onSessionConnect = (session) => {
- session.close();
+ // session.close();
server.close();
};
The error is
I wonder if this depends on another backport. There is a comment above
|
The same error ( I think we can work around the issue by adding a cc: @davedoesdev |
I think the simplest way to fix the issue is diff --git a/test/parallel/test-http2-connect.js b/test/parallel/test-http2-connect.js
index 9ee2e4347f..18cf07b041 100644
--- a/test/parallel/test-http2-connect.js
+++ b/test/parallel/test-http2-connect.js
@@ -96,7 +96,8 @@ const { connect: tlsConnect } = require('tls');
const clientOptions = {
port,
- rejectUnauthorized: false
+ rejectUnauthorized: false,
+ ALPNProtocols: ['h2']
};
const socket = tlsConnect(clientOptions, mustCall(onSocketConnect));
})); |
@lpinca seems a reasonable workaround. |
The TLS handshake completes, but without the |
Might be some state not updated in the HTTP/2 library. Out of interest, does the issue still occur with const onSessionConnect = (session) => process.nextTick(() => {
session.close();
server.close();
}); (or |
@davedoesdev yes the test fails with a |
Without this, the session is destroyed with the following error ``` Error [ERR_HTTP2_ERROR]: Protocol error at Http2Session.onSessionInternalError (internal/http2/core.js:756:26) Emitted 'error' event on ClientHttp2Session instance at: at emitClose (internal/http2/core.js:1010:10) at internal/http2/core.js:1048:7 at finish (internal/streams/writable.js:731:5) at processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'ERR_HTTP2_ERROR', errno: -505 } ``` The test then calls `session.close()` which tries to write to a destroyed socket. As a result, an unhandled `ECONNRESET` error is emitted in the v12 release line. PR-URL: nodejs#35482 Refs: nodejs#34859 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
Without this, the session is destroyed with the following error ``` Error [ERR_HTTP2_ERROR]: Protocol error at Http2Session.onSessionInternalError (internal/http2/core.js:756:26) Emitted 'error' event on ClientHttp2Session instance at: at emitClose (internal/http2/core.js:1010:10) at internal/http2/core.js:1048:7 at finish (internal/streams/writable.js:731:5) at processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'ERR_HTTP2_ERROR', errno: -505 } ``` The test then calls `session.close()` which tries to write to a destroyed socket. As a result, an unhandled `ECONNRESET` error is emitted in the v12 release line. PR-URL: nodejs#35482 Refs: nodejs#34859 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
Without this, the session is destroyed with the following error ``` Error [ERR_HTTP2_ERROR]: Protocol error at Http2Session.onSessionInternalError (internal/http2/core.js:756:26) Emitted 'error' event on ClientHttp2Session instance at: at emitClose (internal/http2/core.js:1010:10) at internal/http2/core.js:1048:7 at finish (internal/streams/writable.js:731:5) at processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'ERR_HTTP2_ERROR', errno: -505 } ``` The test then calls `session.close()` which tries to write to a destroyed socket. As a result, an unhandled `ECONNRESET` error is emitted in the v12 release line. PR-URL: #35482 Refs: #34859 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
secureConnecting is never set to false on client TLS sockets. So if Http2Session constructor (in lib/internal/http2/core.js) is called after secureConnect is emitted, then it will wrongly wait for a secureConnect event. This fix sets secureConnecting to false when a client TLS socket has connected. Backport-PR-URL: #34859 PR-URL: #33209 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
Without this, the session is destroyed with the following error ``` Error [ERR_HTTP2_ERROR]: Protocol error at Http2Session.onSessionInternalError (internal/http2/core.js:756:26) Emitted 'error' event on ClientHttp2Session instance at: at emitClose (internal/http2/core.js:1010:10) at internal/http2/core.js:1048:7 at finish (internal/streams/writable.js:731:5) at processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'ERR_HTTP2_ERROR', errno: -505 } ``` The test then calls `session.close()` which tries to write to a destroyed socket. As a result, an unhandled `ECONNRESET` error is emitted in the v12 release line. Backport-PR-URL: #34859 PR-URL: #35482 Refs: #34859 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
landed in 3b55adc...9ab53b4 |
secureConnecting is never set to false on client TLS sockets. So if Http2Session constructor (in lib/internal/http2/core.js) is called after secureConnect is emitted, then it will wrongly wait for a secureConnect event. This fix sets secureConnecting to false when a client TLS socket has connected. Backport-PR-URL: #34859 PR-URL: #33209 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
Without this, the session is destroyed with the following error ``` Error [ERR_HTTP2_ERROR]: Protocol error at Http2Session.onSessionInternalError (internal/http2/core.js:756:26) Emitted 'error' event on ClientHttp2Session instance at: at emitClose (internal/http2/core.js:1010:10) at internal/http2/core.js:1048:7 at finish (internal/streams/writable.js:731:5) at processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'ERR_HTTP2_ERROR', errno: -505 } ``` The test then calls `session.close()` which tries to write to a destroyed socket. As a result, an unhandled `ECONNRESET` error is emitted in the v12 release line. Backport-PR-URL: #34859 PR-URL: #35482 Refs: #34859 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
Without this, the session is destroyed with the following error ``` Error [ERR_HTTP2_ERROR]: Protocol error at Http2Session.onSessionInternalError (internal/http2/core.js:756:26) Emitted 'error' event on ClientHttp2Session instance at: at emitClose (internal/http2/core.js:1010:10) at internal/http2/core.js:1048:7 at finish (internal/streams/writable.js:731:5) at processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'ERR_HTTP2_ERROR', errno: -505 } ``` The test then calls `session.close()` which tries to write to a destroyed socket. As a result, an unhandled `ECONNRESET` error is emitted in the v12 release line. PR-URL: nodejs#35482 Refs: nodejs#34859 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
secureConnecting is never set to false on client TLS sockets.
So if Http2Session constructor (in lib/internal/http2/core.js) is
called after secureConnect is emitted, then it will wrongly wait
for a secureConnect event.
This fix sets secureConnecting to false when a client TLS socket
has connected.
PR-URL: #33209
Reviewed-By: Luigi Pinca [email protected]
Reviewed-By: Sam Roberts [email protected]