diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 5d07dc9e82..123c20581c 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -252,13 +252,24 @@ module.exports = class Router apiRouter.get "/status/compiler/:Project_id", AuthorizationMiddlewear.ensureUserCanReadProject, (req, res) -> sendRes = _.once (statusCode, message)-> - res.writeHead statusCode - res.end message - CompileManager.compile req.params.Project_id, "test-compile", {}, () -> - sendRes 200, "Compiler returned in less than 10 seconds" - setTimeout (() -> + res.status statusCode + res.send message + # set a timeout + handler = setTimeout (() -> sendRes 500, "Compiler timed out" + handler = null ), 10000 + # use a valid user id for testing + test_user_id = "123456789012345678901234" + # run the compile + CompileManager.compile req.params.Project_id, test_user_id, {}, (error, status) -> + clearTimeout handler if handler? + if error? + sendRes 500, "Compiler returned error #{error.message}" + else if status is "success" + sendRes 200, "Compiler returned in less than 10 seconds" + else + sendRes 500, "Compiler returned failure #{status}" apiRouter.get "/ip", (req, res, next) -> res.send({