Closed
Description
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
Labels
Type
Projects
Status
Triaged