Skip to content

http2 sessions aren't cleaned up properly, server can't close #18176

@grantila

Description

@grantila
  • Version: 9.4.0
  • Platform: Darwin 17.3.0
  • Subsystem: http2

9.4 (most likely #17406) broke my unit tests in fetch-h2, sessions not being closed/destroyed properly anymore. I tried to call close( ) before destroy( ) on my sessions, which would cause horrible code to support older Node.js versions:

if ( typeof session.close === 'function' ) session.close( );
session.destroy( );

but that didn't help.

Case:
My unit tests create a server and a client, does things, and then cleans up the client and server connections by terminating their corresponding sessions using session.destroy( ). Finally, I wait for the server to be closed, using server.close( resolve ); (in a promise constructor as you see). This now fails - the close callback of the server is never called. According to its spec, it'll be called when all connections are gone, so I suspect the sessions aren't cleaned up properly when destroy( ) is called.

Do you have any unit tests in Node.js that does something similar - expecting sessions to actually be cleaned up, and/or for an (H2) server's close(cb) to actually call its callback? Otherwise, I'd strongly recommend having such.

I don't have time (right now) to write a minimal code example for this, but might be able to do so eventually.

Before http2 exits its experimental status, I'd also prefer a condensed paragraph in the docs of the lifecycle management of servers, sessions and streams. It's now spread out to all different functions, callbacks and events in the very large documentation page, making an overview of the lifecycles extremely hard to grasp, and getting the lifecycle handling right is key to us users to be able to write robust code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions