diff --git a/services/web/app/src/Features/Compile/ClsiManager.js b/services/web/app/src/Features/Compile/ClsiManager.js index 2e96a8b3ae..a5a42d4cf1 100644 --- a/services/web/app/src/Features/Compile/ClsiManager.js +++ b/services/web/app/src/Features/Compile/ClsiManager.js @@ -23,6 +23,9 @@ const Metrics = require('@overleaf/metrics') const Errors = require('../Errors/Errors') const VALID_COMPILERS = ['pdflatex', 'latex', 'xelatex', 'lualatex'] +// see clsi: RequestParser.MAX_TIMEOUT +const DEFAULT_TIMEOUT = 600 +const OVERHEAD_SYNC_AND_OUTPUT = 60 * 1000 const ClsiManager = { sendRequest(projectId, userId, options, callback) { @@ -455,10 +458,17 @@ const ClsiManager = { userId, 'compile' ) + const timeout = + OVERHEAD_SYNC_AND_OUTPUT + + ((req.compile && req.compile.options && req.compile.options.timeout) || + DEFAULT_TIMEOUT) * + 1000 + const opts = { url: compileUrl, json: req, method: 'POST', + timeout, } ClsiManager._makeRequest(projectId, opts, (err, response, body) => { if (err != null) { diff --git a/services/web/test/unit/src/Compile/ClsiManagerTests.js b/services/web/test/unit/src/Compile/ClsiManagerTests.js index 4b41bfe8e9..e10fb25071 100644 --- a/services/web/test/unit/src/Compile/ClsiManagerTests.js +++ b/services/web/test/unit/src/Compile/ClsiManagerTests.js @@ -912,7 +912,7 @@ describe('ClsiManager', function () { describe('_postToClsi', function () { beforeEach(function () { - this.req = { mock: 'req', compile: {} } + this.req = { compile: { options: { timeout: 42 } } } }) describe('successfully', function () { @@ -941,6 +941,7 @@ describe('ClsiManager', function () { method: 'POST', url, json: this.req, + timeout: 42 * 1000 + 60 * 1000, }) .should.equal(true) })