From d7a3e0f58c62e8059b23b898782b442f7af4aba4 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Fri, 29 Oct 2021 20:54:57 +0200 Subject: [PATCH 1/2] Don't throw error if gitlab response is not okay-ish Signed-off-by: Tilman Vatteroth --- lib/response.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/response.js b/lib/response.js index 4d22d563..44696a55 100644 --- a/lib/response.js +++ b/lib/response.js @@ -153,7 +153,9 @@ function gitlabActionProjects (req, res, note) { id: req.user.id } }).then(function (user) { - if (!user) { return errors.errorNotFound(res) } + if (!user) { + return errors.errorNotFound(res) + } const ret = { baseURL: config.gitlab.baseURL, version: config.gitlab.version } ret.accesstoken = user.accessToken ret.profileid = user.profileid @@ -161,12 +163,14 @@ function gitlabActionProjects (req, res, note) { fetch(apiUrl).then(resp => { if (!resp.ok) { res.send(ret) - throw new Error('HTTP request returned not okay-ish status') + return Promise.reject(new Error('HTTP request returned not okay-ish status')) } return resp.json() }).then(body => { ret.projects = body return res.send(ret) + }).catch(err => { + logger.error('gitlab action projects failed: ', err) }) }).catch(function (err) { logger.error('gitlab action projects failed: ' + err) From 489f785992ab6918c4520b29bb69bef23a02afc2 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Thu, 4 Nov 2021 20:49:53 +0100 Subject: [PATCH 2/2] Set global timeout for Ajax operations `ajaxSetup()` sets the default values for future Ajax operations. See also https://api.jquery.com/jQuery.ajaxSetup/ https://api.jquery.com/jquery.ajax/ Signed-off-by: David Mehren --- public/js/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/js/index.js b/public/js/index.js index 80b23d27..a61a3c3c 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -621,6 +621,11 @@ Visibility.change(function (e, state) { // when page ready $(document).ready(function () { + // set global ajax timeout + $.ajaxSetup({ + timeout: 10000 + }) + idle.checkAway() checkResponsive() // if in smaller screen, we don't need advanced scrollbar