Add UNSAFE last-resort measure to prevent crashes
This is really unsafe, according to Node.js's docs (see link below). Therefore, this handler is only added if the UNSAFE_CONTINUE environment variable has a truthy value. https://nodejs.org/api/process.html#warning-using-uncaughtexception-correctly
This commit is contained in:
parent
4ff19c9fa5
commit
a9e3b27cb5
1 changed files with 8 additions and 0 deletions
8
app.js
8
app.js
|
|
@ -44,4 +44,12 @@ server.on('upgrade', (req, socket, head) => {
|
||||||
|
|
||||||
server.listen(PORT);
|
server.listen(PORT);
|
||||||
|
|
||||||
|
if (process.env.UNSAFE_CONTINUE)
|
||||||
|
process.on("uncaughtException", (err, origin) => {
|
||||||
|
console.error(`Critical error (${origin}):`)
|
||||||
|
console.error(err)
|
||||||
|
console.error("UNSAFELY CONTINUING EXECUTION")
|
||||||
|
console.error()
|
||||||
|
})
|
||||||
|
|
||||||
console.log(`Server running at http://localhost:${PORT}/.`);
|
console.log(`Server running at http://localhost:${PORT}/.`);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue