-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
socket.connecting
is false before calling the connect listener
#25328
Comments
You didn't say whether you felt the docs were wrong or the behaviour was wrong, but reading behind the lines, I think you found the docs unclear. Does #25333 help? |
I've said that indirectly. Anyway, I'm saying it now: I feel the behavior is wrong.
👍, but I still don't know if the described behavior above is right or it's just a bug. |
I don't understand why you think its a bug. You provided code, but what is it about the code that you think is wrong? What do you think it should do differently? |
I think it should do differently because the connection hasn't been fully estabilished yet. |
Or maybe there's another way to check if the socket has been estabilished? |
You don't want to know when the TCP connection is established, it seems you want to know when the TLS handshake has completed. .connecting does not, as you see, tell you that. Maybe tls.TLSSocket should override the meaning of the The callback function to Generally, waiting for events is preferred to polling properties for their state, but on the client side you could look at https://nodejs.org/api/tls.html#tls_tlssocket_authorized, it will be set to true just before |
Nope (maybe?) 😄 I want to see if the TCP connection has been established: for example,
Good to know ^_^ |
Then you can use the
to
|
You don't get it. This issue is not solved yet.
It's no difference if I add the connect listener through
I have no idea how many times I've told you that Could you reopen this issue? Otherwise I'll make a new one. |
.connecting is supposed to become false before the connect event is emitted, as documented, and as implemented: Lines 1057 to 1066 in 9dfbc39
Your example code shows that .connecting becomes false before the secureConnect event, as it should do. This is unrelated to your assertion (since it doesn't use the connect event). Please provide example code, with a clear description of what about that code's behaviour you believe to be a bug. |
Thanks for your interest, I really appreciate it! 🙌 Here's the example: https://runkit.com/szmarczak/5c2fc4a004d48e001292057c On the |
@Trott I think this should be moved to nodejs/help
Sorry, while I am not an expert in the HTTP sub-system, this doesn't surprise me. You are probably seeing the finish event before the underlying socket has had Also, there is connection pooling by the agent with request. Its possible that the socket was already connected, and is being reused, in which case an http.request() will not even cause a .connect() call to be made on a socket. I'd suggest asking in nodejs/help, describing what you are trying to accomplish, and perhaps someone can help you find a way. |
Fixes: nodejs#25328 PR-URL: nodejs#25333 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Hmm. I assumed that Sorry for disturbing you guys. Feel free to move this to the help repo. |
According to the docs:
I don't think
socket.connecting
should befalse
before emitting theconnect
event.Demo: https://runkit.com/szmarczak/5c2e555cc7b0160012352b15
It breaks for example
http-timer
.The text was updated successfully, but these errors were encountered: