Description
What is the problem this feature will solve?
As noted in https://nodejs.org/dist/latest-v16.x/docs/api/net.html#serverclosecallback, a net.Server
will not fully close until all persistent (keep-alive) connections have reached the end of their timeout. In other languages/frameworks, e.g. Java, C#, or PHP, this is not a problem because applications written with them are typically hosted within a dedicated HTTP server that will deal with this on the application's behalf. However, if we look at another language in which applications are typically written to provide a direct HTTP server we can see that this problem showed up there and has been solved -- golang/go#4674 (comment) (final resolution https://go.dev/doc/go1.8#http_shutdown):
HTTP Server Graceful Shutdown
The HTTP Server now has support for graceful shutdown using the new Server.Shutdown method and abrupt shutdown using the new Server.Close method.
What is the feature you are proposing to solve the problem?
I propose that Node.js internally track persistent connections and provide a method to forcefully close them.
What alternatives have you considered?
We have implemented a, what I would call hacky, solution for this in Fastify -- fastify/fastify#3619
The hope is that if Node.js internalizes it, it can be more performant.