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

How to find out when a http session is done #15387

Closed
ronag opened this issue Sep 13, 2017 · 1 comment
Closed

How to find out when a http session is done #15387

ronag opened this issue Sep 13, 2017 · 1 comment
Labels
http Issues or PRs related to the http subsystem. http2 Issues or PRs related to the http2 subsystem. question Issues that look for answers.

Comments

@ronag
Copy link
Member

ronag commented Sep 13, 2017

I would like to run some code whenever a http session is complete, done and nothing else will be emitted or run on any associated request, response or socket objects. And it should always be invoked regardless whether there has been an error, has a response, aborted or properly finished.

And I'd like to do this for http.ClientRequest as well as http and http2.

I thought, the close event on the request objects would do the trick. But sometimes it's not called at all, sometimes it's called but then later an error is invoked anyway or some event on the response object is invoked.

What's the practice here? Do we have any unit tests for this?

I guess this is what on-finished is for. But I'm not sure if that is for legacy reasons and whether it will work for http2 or if it's a best practise at all. It allocates some closures.

@mscdex mscdex added http Issues or PRs related to the http subsystem. http2 Issues or PRs related to the http2 subsystem. question Issues that look for answers. labels Sep 13, 2017
@jasnell
Copy link
Member

jasnell commented Nov 26, 2017

The Http2Session instance will emit a close event when it is complete.

@jasnell jasnell closed this as completed Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem. http2 Issues or PRs related to the http2 subsystem. question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

3 participants