Skip to content

closeAllConnections on http2.Http2Server and http2.Http2SecureServer  #55459

Closed
@hildjj

Description

@hildjj

What is the problem this feature will solve?

I would like to cleanly shut down a running http2 server that has existing client connections. In http.Server, the closeAllConnections method was added for this purpose, but it doesn't seem to have been included in http2 yet.

What is the feature you are proposing to solve the problem?

Add the methose closeAllConnections() and closeIdleConnections to http2.Http2Server and http2.Http2SecureServer.

Alternatively, if an AbortSignal is passed into listen(), all connections could be shut down when the signal fires abort.

What alternatives have you considered?

This code is a workaround:

const socks = new Set();
const server = http2.createSecureServer(...);
server.on('connection', (s: Duplex) => {
  socks.add(s);
  once('close', () => socks.delete(s));
});
server.on('close', () => {
  for (const s of socks) {
    s.destroy(); // Fires close event above, which cleans up.
  }
});

This is likely suboptimal due to my lack of intimate understanding of the http2 implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.http2Issues or PRs related to the http2 subsystem.stale

    Type

    No type

    Projects

    Status

    Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions