Add an error handler to Express to dump OIDC errors with uuid
parent
e039423dd5
commit
e950ec9dbe
|
|
@ -35,6 +35,7 @@ const RedisStore = require('connect-redis')(expressSession);
|
||||||
const sharedSession = require('express-socket.io-session');
|
const sharedSession = require('express-socket.io-session');
|
||||||
const interactiveServer = require('./lib/interactiveServer');
|
const interactiveServer = require('./lib/interactiveServer');
|
||||||
const promExporter = require('./lib/promExporter');
|
const promExporter = require('./lib/promExporter');
|
||||||
|
const { v4: uuidv4 } = require('uuid');
|
||||||
|
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.log('- process.env.DEBUG:', process.env.DEBUG);
|
console.log('- process.env.DEBUG:', process.env.DEBUG);
|
||||||
|
|
@ -157,6 +158,24 @@ async function run()
|
||||||
// Run WebSocketServer.
|
// Run WebSocketServer.
|
||||||
await runWebSocketServer();
|
await runWebSocketServer();
|
||||||
|
|
||||||
|
function errorHandler(err, req, res, next)
|
||||||
|
{
|
||||||
|
const trackingId = uuidv4();
|
||||||
|
|
||||||
|
res.status(500).send(
|
||||||
|
`<h1>Internal Server Error</h1>
|
||||||
|
<p>If you report this error, please also report this
|
||||||
|
<i>tracking ID</i> which makes it possible to locate your session
|
||||||
|
in the logs which are available to the system administrator:
|
||||||
|
<b>${trackingId}</b></p>`
|
||||||
|
);
|
||||||
|
logger.error(
|
||||||
|
'Express error handler dump with tracking ID: %s, error dump: %o',
|
||||||
|
trackingId, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
app.use(errorHandler);
|
||||||
|
|
||||||
// Log rooms status every 30 seconds.
|
// Log rooms status every 30 seconds.
|
||||||
setInterval(() =>
|
setInterval(() =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue