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

closeAllConnections on http2.Http2Server and http2.Http2SecureServer #55459

Open
hildjj opened this issue Oct 19, 2024 · 0 comments
Open

closeAllConnections on http2.Http2Server and http2.Http2SecureServer #55459

hildjj opened this issue Oct 19, 2024 · 0 comments
Labels
feature request Issues that request new features to be added to Node.js. http2 Issues or PRs related to the http2 subsystem.

Comments

@hildjj
Copy link

hildjj commented Oct 19, 2024

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.

@hildjj hildjj added the feature request Issues that request new features to be added to Node.js. label Oct 19, 2024
@RedYetiDev RedYetiDev added the http2 Issues or PRs related to the http2 subsystem. label Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. http2 Issues or PRs related to the http2 subsystem.
Projects
Development

No branches or pull requests

2 participants