From 523db1a1972d13dee05bfcf6c14523cb55b6e5b7 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 17 Mar 2024 20:12:45 +0100 Subject: [PATCH] fix(nuxt): ignore failures to access asyncContext in environments without it --- packages/nuxt/src/core/runtime/nitro/dev-server-logs.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/core/runtime/nitro/dev-server-logs.ts b/packages/nuxt/src/core/runtime/nitro/dev-server-logs.ts index b1fd618e00..b7efca61e4 100644 --- a/packages/nuxt/src/core/runtime/nitro/dev-server-logs.ts +++ b/packages/nuxt/src/core/runtime/nitro/dev-server-logs.ts @@ -44,12 +44,15 @@ export default (nitroApp: NitroApp) => { }) nitroApp.hooks.hook('afterResponse', () => { - const ctx = asyncContext.use() + const ctx = asyncContext.tryUse() + if (!ctx) { return } return nitroApp.hooks.callHook('dev:ssr-logs', { logs: ctx.logs, path: ctx.event.path }) }) // Pass any logs to the client nitroApp.hooks.hook('render:html', (htmlContext) => { + const ctx = asyncContext.tryUse() + if (!ctx) { return } htmlContext.bodyAppend.unshift(``) }) }