mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
24 lines
605 B
JavaScript
24 lines
605 B
JavaScript
import { cliLog } from './log'
|
|
|
|
export function injectRequestContext() {
|
|
const _globalThis = globalThis
|
|
|
|
/** @type {import('next/dist/server/after/builtin-request-context').BuiltinRequestContext} */
|
|
_globalThis[Symbol.for('@next/request-context')] = {
|
|
get() {
|
|
return {
|
|
waitUntil(/** @type {Promise<any>} */ promise) {
|
|
cliLog('waitUntil from "@next/request-context" was called')
|
|
promise.catch((err) => {
|
|
console.error(err)
|
|
})
|
|
},
|
|
}
|
|
},
|
|
}
|
|
|
|
return () => {
|
|
delete _globalThis[Symbol.for('@next/request-context')]
|
|
}
|
|
}
|