Просмотр исходного кода

Merge pull request #14562 from overleaf/jpa-disable-connection-checking

[web] workaround for broken detection of idle connections in CI

GitOrigin-RevId: ae9ff2b9b1bf99b56d8eb1af6e035b6ed08f7477
Jakob Ackermann 3 лет назад
Родитель
Сommit
6b61d906ba

+ 9 - 1
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')) {

+ 10 - 1
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)

+ 9 - 1
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)