File size: 875 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import { BailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
import { workAsyncStorage } from '../../server/app-render/work-async-storage.external'
import { workUnitAsyncStorage } from '../../server/app-render/work-unit-async-storage.external'
export function bailoutToClientRendering(reason: string): void | never {
const workStore = workAsyncStorage.getStore()
if (workStore?.forceStatic) return
const workUnitStore = workUnitAsyncStorage.getStore()
if (workUnitStore) {
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
throw new BailoutToCSRError(reason)
case 'request':
case 'cache':
case 'private-cache':
case 'unstable-cache':
break
default:
workUnitStore satisfies never
}
}
}
|