Skip to content
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

http2.connect callback not called if createConnection returns a socket that's already connected #19839

Closed
pietermees opened this issue Apr 5, 2018 · 2 comments

Comments

@pietermees
Copy link
Contributor

  • Version: v9.10.1
  • Platform: all
  • Subsystem: http2

http2.connect accepts a callback that is invoked when the Http2Session is in a connected state by adding the callback as a listener to the Http2Session connect event here:

session.once('connect', listener);

However, when one provides the createConnection option and the provided function returns a Socket that is already connected to a remote host, the Http2Session constructor will synchronously raise the connect event, causing the http2.connect listener to not be fired:

if (socket.connecting) {

The following two changes could resolve the issue:

  1. Expose an Http2Session#connecting property, just like Socket#connecting so the connection state of the Http2Session can be inspected after the constructor has returned
  2. Modify http2.connect to check session.connecting to choose between invoking listener immediately or adding it as a listener to the session's connect event.
@pietermees
Copy link
Contributor Author

Actually, it seems like there is already a connecting property on Http2Session, it's just not documented:

get connecting() {

@apapirovski
Copy link
Member

Fixed by #19842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants