Merge pull request #4251 from overleaf/jpa-compile-request-timeout

[ClsiManager] timeout compile request

GitOrigin-RevId: 0213bb93bbdc9a75c07b27226b780dff5ee6f732
This commit is contained in:
Jakob Ackermann 2021-06-23 12:38:02 +02:00 committed by Copybot
parent 7c97f8ab6e
commit 7b5aa23285
2 changed files with 12 additions and 1 deletions

View file

@ -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) {

View file

@ -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)
})