Files
hedgedoc-hedgeagent/lib/web/middleware/tooBusy.js
Daniel Koschützki c94ccfb6de fix: Dont return toobusy errors for healthchecks.
If running with an orchestrator that restarts hedgedoc on failing
healthchecks, this causes it to enter a crashloop.

toobusy -> gets restarted -> everyone refreshes -> toobusy

Signed-off-by: Daniel Koschützki <daniel.koschuetzki@adfinis.com>
2025-08-14 15:31:09 +02:00

22 lines
465 B
JavaScript

'use strict'
const toobusy = require('toobusy-js')
const errors = require('../../errors')
const config = require('../../config')
toobusy.maxLag(config.tooBusyLag)
module.exports = function (req, res, next) {
// We dont want to return "toobusy" errors for healthchecks, as that
// will cause the process to be restarted
if (req.baseUrl === '/_health') {
next()
}
if (toobusy()) {
errors.errorServiceUnavailable(res)
} else {
next()
}
}