From c7006fabd41ef7239a4f3ee087f5911d4a50c772 Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Fri, 21 Jul 2023 09:10:33 +0100 Subject: [PATCH] Merge pull request #13980 from overleaf/mj-web-compile-timeout [web] Add timeout for compile requests to clsi GitOrigin-RevId: 94d6de60eec1fc9e52971e14f38f2d4aef6b7f5d --- services/web/app/src/Features/Compile/ClsiManager.js | 4 ++++ services/web/test/unit/src/Compile/ClsiManagerTests.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/services/web/app/src/Features/Compile/ClsiManager.js b/services/web/app/src/Features/Compile/ClsiManager.js index 11d4facb7e..166daeba8b 100644 --- a/services/web/app/src/Features/Compile/ClsiManager.js +++ b/services/web/app/src/Features/Compile/ClsiManager.js @@ -29,6 +29,9 @@ const VALID_COMPILERS = ['pdflatex', 'latex', 'xelatex', 'lualatex'] const OUTPUT_FILE_TIMEOUT_MS = 60000 const CLSI_COOKIES_ENABLED = (Settings.clsiCookie?.key ?? '') !== '' +// The timeout in services/clsi/app.js is 10 minutes, so we'll be on the safe side with 12 minutes +const COMPILE_REQUEST_TIMEOUT_MS = 12 * 60 * 1000 + function collectMetricsOnBlgFiles(outputFiles) { let topLevel = 0 let nested = 0 @@ -451,6 +454,7 @@ async function _postToClsi( const opts = { json: req, method: 'POST', + signal: AbortSignal.timeout(COMPILE_REQUEST_TIMEOUT_MS), } try { const { body, clsiServerId } = await _makeRequest( diff --git a/services/web/test/unit/src/Compile/ClsiManagerTests.js b/services/web/test/unit/src/Compile/ClsiManagerTests.js index 6620ac1af9..f7c38c8c52 100644 --- a/services/web/test/unit/src/Compile/ClsiManagerTests.js +++ b/services/web/test/unit/src/Compile/ClsiManagerTests.js @@ -222,6 +222,7 @@ describe('ClsiManager', function () { 'Content-Type': 'application/json', Cookie: `${this.clsiCookieKey}=${this.clsiServerId}`, }, + signal: sinon.match.instanceOf(AbortSignal), } ) }) @@ -426,6 +427,7 @@ describe('ClsiManager', function () { 'Content-Type': 'application/json', Cookie: `${this.clsiCookieKey}=${this.clsiServerId}`, }, + signal: sinon.match.instanceOf(AbortSignal), } ) }) @@ -829,6 +831,7 @@ describe('ClsiManager', function () { 'Content-Type': 'application/json', Cookie: `${this.clsiCookieKey}=${this.clsiServerId}`, }, + signal: sinon.match.instanceOf(AbortSignal), } ) })