-
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
Http2Session emits 'connect' event while socket is still connecting #49860
Comments
|
Hey!! I am quite new to the code base, what i didnt understand was why in the first place is node not assuring that the socket is connected, would it be plausible if the condition is changed from socket.connecting to checking if the socket is connected or not already. Asking because since the issue is with jsstreamsocket connection only, would it be right to change the condition all over or should i search for a way to return from jsstreamsocket itself that the socket has connected? |
Version
Tested with v20.7.0 and v18.17.1
Platform
Probably platform independent. Darwin MacBook-Pro-M1-Max.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64
Subsystem
http2
What steps will reproduce the bug?
When
createConnection
returns a socket that hasconnecting === true
but no_handle
set, the Http2Session constructor will wrap the socket with aJSStreamSocket
and this wrapper will not reflect that the underlying socket is still connecting. The session will then emit a 'connect' event while the socket is still connecting.Code demonstrating the issue when connecting to a port that is not being listened on:
The output:
The 'connect' event is unexpected.
Setting the
_handle
as the commented 2 lines of code suggest can trick the constructor of Http2Session into not wrapping the socket and wait for the socket to emit a 'connect' event before emitting 'connect' itself. This is provided only illustration, setting_handle
this way is not expected to be a valid workaround.Code pointers:
_handle
is undefined:node/lib/internal/http2/core.js
Line 1208 in a94966f
connecting === true
and the check of Http2Session whether the socket (now the wrapper) is still connecting does not trigger:node/lib/internal/http2/core.js
Line 1256 in a94966f
How often does it reproduce? Is there a required condition?
Always reproduces with the above sample code.
What is the expected behavior? Why is that the expected behavior?
Http2Session should only emit a 'connect' event once the underlying socket is connected.
What do you see instead?
Http2Session emits 'connect' event while socket is still connecting.
Additional information
No response
The text was updated successfully, but these errors were encountered: