Skip to content

Commit 47e97f0

Browse files
authored
Change the default Keep-Alive timeout to 95 seconds (#371)
For consistency with the timeouts used by other languages: - heroku/heroku-buildpack-php#823 - heroku/ruby-getting-started#190 - heroku/python-getting-started#263
1 parent 8921b54 commit 47e97f0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ const server = app.listen(port, () => {
1818
console.log(`Listening on ${port}`)
1919
})
2020

21+
// The number of seconds an idle Keep-Alive connection is kept open. This should be greater than the Heroku Router's
22+
// Keep-Alive idle timeout of 90 seconds:
23+
// - to ensure that the closing of idle connections is always initiated by the router and not the Node.js server
24+
// - to prevent a race condition if the router sends a request to the app just as Node.js is closing the connection
25+
// https://devcenter.heroku.com/articles/http-routing#keepalives
26+
// https://nodejs.org/api/http.html#serverkeepalivetimeout
27+
server.keepAliveTimeout = 95 * 1000
28+
2129
process.on('SIGTERM', async () => {
2230
console.log('SIGTERM signal received: gracefully shutting down')
2331
if (server) {

0 commit comments

Comments
 (0)