Unverified Commit 2aca0957 authored by James Ide's avatar James Ide Committed by Michaël Zasso
Browse files

http2: release request()'s "connect" event listener after it runs

The `Http2Session#request()` method internally listens to the "connect"
event if the session has not yet established a connection so that the
actual request can be sent after the connection has been established.

This commit removes the event listener after it runs and carries out
the request and is no longer needed. In practice this shouldn't affect
the behavior of the session object since the "connect" event fires only
once anyway, but removing the listener releases its references. The
rest of this class subscribes to the "connect" event with `once`
instead of `on` as well.

Tested by adding a new test that ensures `Http2Session#request()` is
called before the connection is established, indicated by a "connect"
listener that is run. The test also ensures all "connect" listeners are
removed after the connection is established.

PR-URL: https://github.com/nodejs/node/pull/21916


Reviewed-By: default avatarMichaël Zasso <targos@protonmail.com>
Reviewed-By: default avatarTrivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: default avatarAnna Henningsen <anna@addaleax.net>
Reviewed-By: default avatarAnatoli Papirovski <apapirovski@mac.com>
Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarMatteo Collina <matteo.collina@gmail.com>
parent 8c6d1a06
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment