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
+10 -3

No files matched your search

+7 -2
View File
@@ -1211,12 +1211,17 @@ export function listener(
})
.catch((err) => {
currentSessions.delete(httpResponse.connection);
httpResponse.writeHead(500, { Connection: "close" });
httpResponse.end(`${err.name}: ${err.message}`);
stats.concurrentRequests -= 1;
setTimeout(() => {
throw err;
});
try {
httpResponse.connection.unref();
httpResponse.writeHead(500, { Connection: "close" });
httpResponse.end(`${err.name}: ${err.message}`);
} catch (err) {
// Ignore
}
});
}