From ae9f415e6880a67eb6aa9c9c94822e8fc943fe87 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 8 May 2022 11:44:29 +0200 Subject: [PATCH 1/5] Improve error handler to include stacktrace --- src/runtime/entries/node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/entries/node.ts b/src/runtime/entries/node.ts index 693ad05ad9..edba70e8da 100644 --- a/src/runtime/entries/node.ts +++ b/src/runtime/entries/node.ts @@ -3,5 +3,5 @@ import { nitroApp } from '../app' export const handler = nitroApp.h3App.nodeHandler -process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection] ' + err)) -process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException] ' + err)) +process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) +process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) From 69d098fd0b482d85f328acfd634f7f08ae4b3cab Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 8 May 2022 11:45:36 +0200 Subject: [PATCH 2/5] Also in prerender --- src/runtime/entries/nitro-prerenderer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/entries/nitro-prerenderer.ts b/src/runtime/entries/nitro-prerenderer.ts index 17a01f06f8..cce3f023df 100644 --- a/src/runtime/entries/nitro-prerenderer.ts +++ b/src/runtime/entries/nitro-prerenderer.ts @@ -3,5 +3,5 @@ import { nitroApp } from '../app' export const localFetch = nitroApp.localFetch -process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection] ' + err)) -process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException] ' + err)) +process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) +process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) From fecff221e272bc501fc6ed6252b67d60a35994f1 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 8 May 2022 11:46:29 +0200 Subject: [PATCH 3/5] and node-server --- src/runtime/entries/node-server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/entries/node-server.ts b/src/runtime/entries/node-server.ts index 845bf5be1f..d7f9d54944 100644 --- a/src/runtime/entries/node-server.ts +++ b/src/runtime/entries/node-server.ts @@ -23,7 +23,7 @@ server.listen(port, hostname, (err) => { console.log(`Listening on ${protocol}://${hostname}:${port}${useRuntimeConfig().app.baseURL}`) }) -process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection] ' + err)) -process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException] ' + err)) +process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) +process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) export default {} From 70b861bc2edee858a743a4ed8f8b5901bda27ee9 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 8 May 2022 11:47:17 +0200 Subject: [PATCH 4/5] And nitro-dev --- src/runtime/entries/nitro-dev.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/entries/nitro-dev.ts b/src/runtime/entries/nitro-dev.ts index 602928b788..77eb0ba6d0 100644 --- a/src/runtime/entries/nitro-dev.ts +++ b/src/runtime/entries/nitro-dev.ts @@ -34,5 +34,5 @@ server.listen(listenAddress, () => { }) }) -process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection] ' + err)) -process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException] ' + err)) +process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) +process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) From e0928ce0f39e6af625be938e7f92164fd1c3ddfb Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 10 May 2022 16:01:28 +0200 Subject: [PATCH 5/5] enable only with `DEBUG` env --- src/runtime/entries/nitro-dev.ts | 9 +++++++-- src/runtime/entries/nitro-prerenderer.ts | 9 +++++++-- src/runtime/entries/node-server.ts | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/runtime/entries/nitro-dev.ts b/src/runtime/entries/nitro-dev.ts index 77eb0ba6d0..85817eb504 100644 --- a/src/runtime/entries/nitro-dev.ts +++ b/src/runtime/entries/nitro-dev.ts @@ -34,5 +34,10 @@ server.listen(listenAddress, () => { }) }) -process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) -process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) +if (process.env.DEBUG) { + process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) + process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) +} else { + process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection] ' + err)) + process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException] ' + err)) +} diff --git a/src/runtime/entries/nitro-prerenderer.ts b/src/runtime/entries/nitro-prerenderer.ts index cce3f023df..96620a20cb 100644 --- a/src/runtime/entries/nitro-prerenderer.ts +++ b/src/runtime/entries/nitro-prerenderer.ts @@ -3,5 +3,10 @@ import { nitroApp } from '../app' export const localFetch = nitroApp.localFetch -process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) -process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) +if (process.env.DEBUG) { + process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) + process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) +} else { + process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection] ' + err)) + process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException] ' + err)) +} diff --git a/src/runtime/entries/node-server.ts b/src/runtime/entries/node-server.ts index d7f9d54944..ff94121ce2 100644 --- a/src/runtime/entries/node-server.ts +++ b/src/runtime/entries/node-server.ts @@ -23,7 +23,12 @@ server.listen(port, hostname, (err) => { console.log(`Listening on ${protocol}://${hostname}:${port}${useRuntimeConfig().app.baseURL}`) }) -process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) -process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) +if (process.env.DEBUG) { + process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err)) + process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err)) +} else { + process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection] ' + err)) + process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException] ' + err)) +} export default {}