From 37462a063304ff0d756ddd207f4090d6c7bb4964 Mon Sep 17 00:00:00 2001 From: lilnasy <69170106+lilnasy@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:11:10 +0000 Subject: [PATCH 1/2] fix(node): report render error to the terminal --- packages/integrations/node/src/nodeMiddleware.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/integrations/node/src/nodeMiddleware.ts b/packages/integrations/node/src/nodeMiddleware.ts index 32b8020dc199..c8ca4027ee21 100644 --- a/packages/integrations/node/src/nodeMiddleware.ts +++ b/packages/integrations/node/src/nodeMiddleware.ts @@ -51,6 +51,7 @@ export default function (app: NodeApp, mode: Options['mode']) { await writeWebResponse(app, res, response); } } catch (err: unknown) { + console.error(new Error(`Could not render ${req.url}`, { cause: err })) if (!res.headersSent) { res.writeHead(500, `Server error`); res.end(); From 4a376b198c13baff3ce4e8a2d548aa04331e996c Mon Sep 17 00:00:00 2001 From: lilnasy <69170106+lilnasy@users.noreply.github.com> Date: Tue, 19 Sep 2023 22:55:31 +0000 Subject: [PATCH 2/2] use adapter logger --- .changeset/curly-icons-watch.md | 5 +++++ packages/integrations/node/src/nodeMiddleware.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/curly-icons-watch.md diff --git a/.changeset/curly-icons-watch.md b/.changeset/curly-icons-watch.md new file mode 100644 index 000000000000..8c2561904385 --- /dev/null +++ b/.changeset/curly-icons-watch.md @@ -0,0 +1,5 @@ +--- +'@astrojs/node': patch +--- + +The node adapter now logs uncaught errors encountered during rendering a page. diff --git a/packages/integrations/node/src/nodeMiddleware.ts b/packages/integrations/node/src/nodeMiddleware.ts index c8ca4027ee21..eaab0790cbd9 100644 --- a/packages/integrations/node/src/nodeMiddleware.ts +++ b/packages/integrations/node/src/nodeMiddleware.ts @@ -51,7 +51,9 @@ export default function (app: NodeApp, mode: Options['mode']) { await writeWebResponse(app, res, response); } } catch (err: unknown) { - console.error(new Error(`Could not render ${req.url}`, { cause: err })) + const logger = app.getAdapterLogger() + logger.error(`Could not render ${req.url}`) + console.error(err) if (!res.headersSent) { res.writeHead(500, `Server error`); res.end();