From 5e19d710ba465fbd3bb4f120157c1dec00b9e920 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Thu, 22 Oct 2015 20:15:50 +0100 Subject: [PATCH] change error handling on spelling --- .../coffee/Features/Spelling/SpellingController.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/Features/Spelling/SpellingController.coffee b/services/web/app/coffee/Features/Spelling/SpellingController.coffee index 3ac130fb08..81a697525f 100644 --- a/services/web/app/coffee/Features/Spelling/SpellingController.coffee +++ b/services/web/app/coffee/Features/Spelling/SpellingController.coffee @@ -2,13 +2,15 @@ request = require 'request' Settings = require 'settings-sharelatex' logger = require 'logger-sharelatex' +TEN_SECONDS = 1000 * 10 + module.exports = SpellingController = proxyRequestToSpellingApi: (req, res, next) -> url = req.url.slice("/spelling".length) url = "/user/#{req.session.user._id}#{url}" req.headers["Host"] = Settings.apis.spelling.host - getReq = request(url: Settings.apis.spelling.url + url, method: req.method, headers: req.headers, json: req.body) - getReq.on "error", (error) -> + request(url: Settings.apis.spelling.url + url, method: req.method, headers: req.headers, json: req.body, timeout:TEN_SECONDS) + .on "error", (error) -> logger.error err: error, "Spelling API error" res.sendStatus 500 - getReq.pipe(res) + .pipe(res)