- 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:
The following two changes could resolve the issue:
- Expose an
Http2Session#connecting property, just like Socket#connecting so the connection state of the Http2Session can be inspected after the constructor has returned
- 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.