From 6b61d906ba43fe88f831abbb89ef7857571ff313 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 29 Aug 2023 17:37:10 +0200 Subject: [PATCH] Merge pull request #14562 from overleaf/jpa-disable-connection-checking [web] workaround for broken detection of idle connections in CI GitOrigin-RevId: ae9ff2b9b1bf99b56d8eb1af6e035b6ed08f7477 --- services/web/app/src/infrastructure/Server.js | 10 +++++++++- services/web/test/acceptance/src/LinkedFilesTests.js | 11 ++++++++++- .../web/test/acceptance/src/mocks/AbstractMockApi.js | 10 +++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/services/web/app/src/infrastructure/Server.js b/services/web/app/src/infrastructure/Server.js index 5768113ed4..c28d26a684 100644 --- a/services/web/app/src/infrastructure/Server.js +++ b/services/web/app/src/infrastructure/Server.js @@ -303,7 +303,15 @@ if (Settings.csp && Settings.csp.enabled) { } logger.debug('creating HTTP server'.yellow) -const server = require('http').createServer(app) +const server = require('http').createServer( + process.env.NODE_ENV === 'test' + ? { + // Workaround broken detection of idle connections in CI. + connectionsCheckingInterval: 30 * 60 * 1000, + } + : {}, + app +) // provide settings for separate web and api processes if (Settings.enabledServices.includes('api')) { diff --git a/services/web/test/acceptance/src/LinkedFilesTests.js b/services/web/test/acceptance/src/LinkedFilesTests.js index 155bfab0fb..62a4255315 100644 --- a/services/web/test/acceptance/src/LinkedFilesTests.js +++ b/services/web/test/acceptance/src/LinkedFilesTests.js @@ -9,6 +9,7 @@ const express = require('express') const { plainTextResponse, } = require('../../../app/src/infrastructure/Response') +const http = require('http') const LinkedUrlProxy = express() LinkedUrlProxy.get('/', (req, res, next) => { if (req.query.url === 'http://example.com/foo') { @@ -29,7 +30,15 @@ describe('LinkedFiles', function () { let server before(function (done) { - server = LinkedUrlProxy.listen(6543, done) + server = http + .createServer( + { + // Workaround broken detection of idle connections in CI. + connectionsCheckingInterval: 30 * 60 * 1000, + }, + LinkedUrlProxy + ) + .listen(6543, done) }) after(function (done) { server.close(done) diff --git a/services/web/test/acceptance/src/mocks/AbstractMockApi.js b/services/web/test/acceptance/src/mocks/AbstractMockApi.js index 780a49bb5f..b77d69857f 100644 --- a/services/web/test/acceptance/src/mocks/AbstractMockApi.js +++ b/services/web/test/acceptance/src/mocks/AbstractMockApi.js @@ -1,6 +1,7 @@ const OError = require('@overleaf/o-error') const express = require('express') const bodyParser = require('body-parser') +const http = require('http') /** * Abstract class for running a mock API via Express. Handles setting up of @@ -139,7 +140,14 @@ class AbstractMockApi { // eslint-disable-next-line no-console console.log('Starting mock on port', this.constructor.name, this.port) } - this.server = this.app + this.server = http + .createServer( + { + // Workaround broken detection of idle connections in CI. + connectionsCheckingInterval: 30 * 60 * 1000, + }, + this.app + ) .listen(this.port, err => { if (err) { return reject(err)