Skip to content

http2: refactor close/destroy for Http2Stream and Http2Session

This is a significant refactoring of the close/destroy flow and API for Http2Stream and Http2Session. There is quite a bit more to do in here, it's a bit slow going because the flow is rather complex and I'm trying not to break too much as I go.

There are several important bits:

  1. Previously, the destroy operations for both Http2Session and Http2Stream were executed over multiple nextTick and setImmediate hops. Now the objects are unusable immediately when calling destroy() and we're using env->SetImmediate() to handle the need to defer final cleanup (cc @addaleax)

  2. This reworks the destroy and error handling flow between the Http2Session and socket and eliminates the 'socketError' event. Errors occurring on the socket are forwarded to the error event on the associated Http2Session. On the server, those are forwarded to the 'sessionError' event.

  3. Http2Stream.prototype.rstStream() has been renamed to Http2Stream.prototype.close() and the various rstWith.... aliases have been removed.

  4. An improved Http2Session.prototype.close() has been implemented, allowing better API symmetry.

There are still a few more todo's that need to be handled here. Specifically, proper handling of last stream ID on a goaway frame, but this is already a sizable chunk of work. Let's get this reviewed and landed and I'll keep pushing forward.

/cc @nodejs/http2

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

http2

Merge request reports

Loading