Skip to content

Commit

Permalink
fix(server): increase default socket timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Sep 10, 2020
1 parent a5220a0 commit c353ee8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/server/src/server.js
Expand Up @@ -68,6 +68,21 @@ async function createServer(options) {

return new Promise(resolve => {
const server = createHttpServer(app);

// Node default socket timeout is 2 minutes.
// Some LHCI API operations (computing statistics) can take longer than that under heavy load.
// Set the timeout even higher to allow for these requests to complete.
server.on('connection', socket => {
socket.setTimeout(20 * 60 * 1000); // 20 minutes
socket.on('timeout', () => {
if (options.logLevel !== 'silent') {
process.stdout.write(`${new Date().toISOString()} - socket timed out\n`);
}

socket.end();
});
});

server.listen(options.port, () => {
const serverAddress = server.address();
const listenPort =
Expand Down

0 comments on commit c353ee8

Please sign in to comment.