Merge pull request #1790 from hedgedoc/fix-gitlab-response-crash

This commit is contained in:
Yannick Bungers 2021-11-05 09:19:24 +01:00 committed by GitHub
commit 2d811ffeb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -153,7 +153,9 @@ function gitlabActionProjects (req, res, note) {
id: req.user.id id: req.user.id
} }
}).then(function (user) { }).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 } const ret = { baseURL: config.gitlab.baseURL, version: config.gitlab.version }
ret.accesstoken = user.accessToken ret.accesstoken = user.accessToken
ret.profileid = user.profileid ret.profileid = user.profileid
@ -161,12 +163,14 @@ function gitlabActionProjects (req, res, note) {
fetch(apiUrl).then(resp => { fetch(apiUrl).then(resp => {
if (!resp.ok) { if (!resp.ok) {
res.send(ret) 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() return resp.json()
}).then(body => { }).then(body => {
ret.projects = body ret.projects = body
return res.send(ret) return res.send(ret)
}).catch(err => {
logger.error('gitlab action projects failed: ', err)
}) })
}).catch(function (err) { }).catch(function (err) {
logger.error('gitlab action projects failed: ' + err) logger.error('gitlab action projects failed: ' + err)

View file

@ -621,6 +621,11 @@ Visibility.change(function (e, state) {
// when page ready // when page ready
$(document).ready(function () { $(document).ready(function () {
// set global ajax timeout
$.ajaxSetup({
timeout: 10000
})
idle.checkAway() idle.checkAway()
checkResponsive() checkResponsive()
// if in smaller screen, we don't need advanced scrollbar // if in smaller screen, we don't need advanced scrollbar