on domain error wait 3 seconds to send 500 to allow for other cleanup.

Also check inside function if the res has finished. #confused
This commit is contained in:
Henry Oswald 2014-05-07 09:06:05 +01:00
parent be8fdcfd6a
commit 09224007a7
2 changed files with 6 additions and 3 deletions

View file

@ -35,8 +35,10 @@ app.use (req, res, next) ->
requestDomain.add req requestDomain.add req
requestDomain.add res requestDomain.add res
requestDomain.on "error", (err)-> requestDomain.on "error", (err)->
if !res.finished setTimeout(->
res.send(500) if !res.finished
res.send(500)
, 3000)
logger = require('logger-sharelatex') logger = require('logger-sharelatex')
req = req =
body:req.body body:req.body

View file

@ -15,7 +15,8 @@ module.exports =
FileHandler.getFile bucket, key, {format:format,style:style}, (err, fileStream)-> FileHandler.getFile bucket, key, {format:format,style:style}, (err, fileStream)->
if err? if err?
logger.err err:err, key:key, bucket:bucket, format:format, style:style, "problem getting file" logger.err err:err, key:key, bucket:bucket, format:format, style:style, "problem getting file"
res?.send? 500 if !res.finished and res?.send?
res.send 500
else if req.query.cacheWarm else if req.query.cacheWarm
logger.log key:key, bucket:bucket, format:format, style:style, "request is only for cache warm so not sending stream" logger.log key:key, bucket:bucket, format:format, style:style, "request is only for cache warm so not sending stream"
res.send 200 res.send 200