mirror of
https://github.com/thelounge/thelounge
synced 2024-11-10 06:34:21 +00:00
server: don't throw in async callback from index requests
This was flagged as an issue by codeQL > Server crash [High] > The server of this route handler will terminate when an > uncaught exception from this location escapes an > asynchronous callback.
This commit is contained in:
parent
36cb75ee99
commit
8eb398c5cc
1 changed files with 13 additions and 15 deletions
|
@ -406,22 +406,20 @@ function forceNoCacheRequest(_req: Request, res: Response, next: NextFunction) {
|
||||||
function indexRequest(_req: Request, res: Response) {
|
function indexRequest(_req: Request, res: Response) {
|
||||||
res.setHeader("Content-Type", "text/html");
|
res.setHeader("Content-Type", "text/html");
|
||||||
|
|
||||||
return fs.readFile(
|
fs.readFile(Utils.getFileFromRelativeToRoot("client/index.html.tpl"), "utf-8", (err, file) => {
|
||||||
Utils.getFileFromRelativeToRoot("client/index.html.tpl"),
|
if (err) {
|
||||||
"utf-8",
|
log.error(`failed to server index request: ${err.name}, ${err.message}`);
|
||||||
(err, file) => {
|
res.sendStatus(500);
|
||||||
if (err) {
|
return;
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
const config: IndexTemplateConfiguration = {
|
|
||||||
...getServerConfiguration(),
|
|
||||||
...{cacheBust: Helper.getVersionCacheBust()},
|
|
||||||
};
|
|
||||||
|
|
||||||
res.send(_.template(file)(config));
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
const config: IndexTemplateConfiguration = {
|
||||||
|
...getServerConfiguration(),
|
||||||
|
...{cacheBust: Helper.getVersionCacheBust()},
|
||||||
|
};
|
||||||
|
|
||||||
|
res.send(_.template(file)(config));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeClient(
|
function initializeClient(
|
||||||
|
|
Loading…
Reference in a new issue