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: release request()'s "connect" event listener after it runs #21916

Closed
wants to merge 1 commit into from

Conversation

ide
Copy link
Contributor

@ide ide commented Jul 21, 2018

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.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@targos
Copy link
Member

targos commented Jul 21, 2018

/cc @nodejs/http2

@trivikr
Copy link
Member

trivikr commented Jul 22, 2018

@trivikr trivikr added http2 Issues or PRs related to the http2 subsystem. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Jul 22, 2018
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, could you add a unit test for this behavior?

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.
@ide ide force-pushed the http2-onconnect branch from 69d06f7 to 2e6649c Compare July 28, 2018 07:20
@ide
Copy link
Contributor Author

ide commented Jul 28, 2018

@mcollina Thanks for reviewing. I added a unit test that fails without this commit and passes with it.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good work!

@mcollina
Copy link
Member

@targos
Copy link
Member

targos commented Jul 29, 2018

Landed in 2aca095 🎉

@targos targos closed this Jul 29, 2018
targos pushed a commit that referenced this pull request Jul 29, 2018
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: #21916
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
targos pushed a commit that referenced this pull request Jul 31, 2018
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: #21916
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@targos targos mentioned this pull request Jul 31, 2018
kjin pushed a commit to kjin/node that referenced this pull request Aug 23, 2018
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: nodejs#21916
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Sep 25, 2018
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: nodejs#21916
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Oct 16, 2018
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: nodejs#21916
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
BethGriggs pushed a commit that referenced this pull request Oct 17, 2018
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.

Backport-PR-URL: #22850
PR-URL: #21916
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@BethGriggs BethGriggs mentioned this pull request Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants