From a3590558d7845811c22e8365328120c70506611c Mon Sep 17 00:00:00 2001 From: Rostislav Simonik Date: Sun, 27 Jan 2019 10:19:46 +0100 Subject: [PATCH] feat: introduce server keepAliveTimeout into config files Set default timeout to 60 seconds (it's workaround for issue reported in issues/301). --- conf/default.yaml | 6 ++++++ conf/full.yaml | 6 ++++++ src/lib/bootstrap.js | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/conf/default.yaml b/conf/default.yaml index 8e3bb14f6..cdea139da 100644 --- a/conf/default.yaml +++ b/conf/default.yaml @@ -50,6 +50,12 @@ packages: # if package is not available locally, proxy requests to 'npmjs' registry proxy: npmjs +# You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections. +# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout. +# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought. +server: + keepAliveTimeout: 60 + # To use `npm audit` uncomment the following section middlewares: audit: diff --git a/conf/full.yaml b/conf/full.yaml index 1af6251e8..c578e29e4 100644 --- a/conf/full.yaml +++ b/conf/full.yaml @@ -115,6 +115,12 @@ packages: # - [::1]:4873 # ipv6 # - unix:/tmp/verdaccio.sock # unix socket +# You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections. +# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout. +# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought. +server: + keepAliveTimeout: 60 + # Configure HTTPS, it is required if you use "https" protocol above. #https: # key: path/to/server.key diff --git a/src/lib/bootstrap.js b/src/lib/bootstrap.js index 585d41253..1d4ce449a 100644 --- a/src/lib/bootstrap.js +++ b/src/lib/bootstrap.js @@ -89,7 +89,10 @@ function startVerdaccio(config: any, } else { // http webServer = http.createServer(app); } - + if (config.server && config.server.keepAliveTimeout) { + // $FlowFixMe library definition for node is not up to date (doesn't contain recent 8.0 changes) + webServer.keepAliveTimeout = config.server.keepAliveTimeout; + } unlinkAddressPath(addr); callback(webServer, addr, pkgName, pkgVersion);