mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +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', () => {
|
||||
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(`<script>window.__NUXT_LOGS__ = ${devalue(asyncContext.use().logs)}</script>`)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user