Fix unhandled promise rejections

This commit is contained in:
Zaid Abdulla committed 2020-09-17 17:00:41 -07:00
1 parent 328bfa03e0
commit 9286bd6aa0
2 files changed
+9 -2

No files matched your search

+7 -2
View File
@@ -1211,12 +1211,17 @@ export function listener(
}) })
.catch((err) => { .catch((err) => {
currentSessions.delete(httpResponse.connection); currentSessions.delete(httpResponse.connection);
httpResponse.writeHead(500, { Connection: "close" });
httpResponse.end(`${err.name}: ${err.message}`);
stats.concurrentRequests -= 1; stats.concurrentRequests -= 1;
setTimeout(() => { setTimeout(() => {
throw err; throw err;
}); });
try {
httpResponse.connection.unref();
httpResponse.writeHead(500, { Connection: "close" });
httpResponse.end(`${err.name}: ${err.message}`);
} catch (err) {
// Ignore
}
}); });
} }
+2
View File
@@ -60,8 +60,10 @@ const getAuthorizer = memoize(
); );
koa.on("error", async (err) => { koa.on("error", async (err) => {
setTimeout(() => {
throw err; throw err;
}); });
});
koa.use(async (ctx, next) => { koa.use(async (ctx, next) => {
const configSnapshot = await localCache.getCurrentSnapshot(); const configSnapshot = await localCache.getCurrentSnapshot();