mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add timeout to tpds worker
This commit is contained in:
parent
8146dd7ce9
commit
1ec8bdcaea
1 changed files with 17 additions and 1 deletions
|
@ -33,12 +33,20 @@ processingFuncs =
|
|||
else
|
||||
callback()
|
||||
|
||||
pipeStreamFrom: (options, callback)->
|
||||
pipeStreamFrom: (options, _callback)->
|
||||
callback = (args...) ->
|
||||
_callback(args...)
|
||||
_callback = () ->
|
||||
|
||||
if options.filePath == "/droppy/main.tex"
|
||||
request options.streamOrigin, (err,res, body)->
|
||||
logger.log options:options, body:body
|
||||
|
||||
origin = request(options.streamOrigin)
|
||||
|
||||
cancelled = false
|
||||
origin.on 'response', (res) ->
|
||||
return if cancelled
|
||||
if 200 <= res.statusCode < 300
|
||||
dest = request(options)
|
||||
origin.pipe(dest)
|
||||
|
@ -54,9 +62,17 @@ processingFuncs =
|
|||
callback(error)
|
||||
|
||||
origin.on 'error', (err)->
|
||||
return if cancelled
|
||||
logger.error err:err, options:options, "something went wrong in pipeStreamFrom origin"
|
||||
callback(err)
|
||||
|
||||
setTimeout () ->
|
||||
cancelled = true
|
||||
error = new Error("timeout")
|
||||
logger.error err: error, options: options, "timeout"
|
||||
callback(error)
|
||||
, 5000
|
||||
|
||||
|
||||
|
||||
workerRegistration = (groupKey, method, options, callback)->
|
||||
|
|
Loading…
Reference in a new issue