mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-16 21:58:19 +00:00
fix(nuxt): ignore failures to access asyncContext in environments without it
This commit is contained in:
parent
0d9c63b828
commit
523db1a197
@ -44,12 +44,15 @@ export default (nitroApp: NitroApp) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
nitroApp.hooks.hook('afterResponse', () => {
|
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 })
|
return nitroApp.hooks.callHook('dev:ssr-logs', { logs: ctx.logs, path: ctx.event.path })
|
||||||
})
|
})
|
||||||
|
|
||||||
// Pass any logs to the client
|
// Pass any logs to the client
|
||||||
nitroApp.hooks.hook('render:html', (htmlContext) => {
|
nitroApp.hooks.hook('render:html', (htmlContext) => {
|
||||||
|
const ctx = asyncContext.tryUse()
|
||||||
|
if (!ctx) { return }
|
||||||
htmlContext.bodyAppend.unshift(`<script>window.__NUXT_LOGS__ = ${devalue(asyncContext.use().logs)}</script>`)
|
htmlContext.bodyAppend.unshift(`<script>window.__NUXT_LOGS__ = ${devalue(asyncContext.use().logs)}</script>`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user