stop response sending twice if compile takes a long time when testing

This commit is contained in:
Henry Oswald 2014-03-12 21:56:58 +00:00
parent 52cb1a4dcd
commit d20286febd

View file

@ -34,6 +34,7 @@ ProjectDownloadsController = require "./Features/Downloads/ProjectDownloadsContr
FileStoreController = require("./Features/FileStore/FileStoreController") FileStoreController = require("./Features/FileStore/FileStoreController")
TrackChangesController = require("./Features/TrackChanges/TrackChangesController") TrackChangesController = require("./Features/TrackChanges/TrackChangesController")
logger = require("logger-sharelatex") logger = require("logger-sharelatex")
_ = require("underscore")
httpAuth = require('express').basicAuth (user, pass)-> httpAuth = require('express').basicAuth (user, pass)->
isValid = Settings.httpAuthUsers[user] == pass isValid = Settings.httpAuthUsers[user] == pass
@ -190,15 +191,13 @@ module.exports = class Router
app.get '/health_check', HealthCheckController.check app.get '/health_check', HealthCheckController.check
app.get "/status/compiler/:Project_id", SecutiryManager.requestCanAccessProject, (req, res) -> app.get "/status/compiler/:Project_id", SecutiryManager.requestCanAccessProject, (req, res) ->
success = false sendRes = _.once (statusCode, message)->
res.writeHead statusCode
res.end message
CompileManager.compile req.params.Project_id, "test-compile", {}, () -> CompileManager.compile req.params.Project_id, "test-compile", {}, () ->
success = true sendRes 200, "Compiler returned in less than 10 seconds"
res.writeHead 200
res.end "Compiler returned in less than 10 seconds"
setTimeout (() -> setTimeout (() ->
if !success sendRes 500, "Compiler timed out"
res.writeHead 500
res.end "Compiler timed out"
), 10000 ), 10000
req.session.destroy() req.session.destroy()