"1057":"Route \"%s\": Could not validate \\`unstable_instant\\` because the target segment was prevented from rendering, likely due to one of the following errors.",
"1057":"Route \"%s\": Could not validate \\`unstable_instant\\` because the target segment was prevented from rendering, likely due to one of the following errors.",
"1058":"InstantValidationBoundary should only be rendered in SSR",
"1058":"InstantValidationBoundary should only be rendered in SSR",
"1059":"Route \"%s\": Could not validate \\`unstable_instant\\` because the target segment was prevented from rendering, likely due to the following error.",
"1059":"Route \"%s\": Could not validate \\`unstable_instant\\` because the target segment was prevented from rendering, likely due to the following error.",
"1060":"Missing boundary tracking state"
"1060":"Missing boundary tracking state",
"1061":"createPrerenderSearchParamsForClientPage should not be called in a client validation.",
"1062":"\\`import('next/root-params').%s()\\` must not be used within a client component. Next.js should be preventing \\`import('next/root-params').%s()\\` from being included in client components statically, but did not in this case.",
"1063":"`connection` must not be used within a Client Component. Next.js should be preventing `connection` from being included in Client Components statically, but did not in this case.",
"1064":"createServerParamsForRoute should not be called in client contexts.",
"1065":"createServerPathnameForMetadata should not be called in client contexts.",
"1066":"createServerSearchParamsForServerPage should not be called in a client validation."
@@ -625,6 +628,9 @@ export function useDynamicRouteParams(expression: string) {
...
@@ -625,6 +628,9 @@ export function useDynamicRouteParams(expression: string) {
thrownewInvariantError(
thrownewInvariantError(
`\`${expression}\` was called inside a cache scope. Next.js should be preventing ${expression} from being included in server components statically, but did not in this case.`
`\`${expression}\` was called inside a cache scope. Next.js should be preventing ${expression} from being included in server components statically, but did not in this case.`
)
)
case'validation-client':
// TODO(instant-validation): in build, this depends on samples
break
case'prerender-legacy':
case'prerender-legacy':
case'request':
case'request':
case'unstable-cache':
case'unstable-cache':
...
@@ -649,6 +655,9 @@ export function useDynamicSearchParams(expression: string) {
...
@@ -649,6 +655,9 @@ export function useDynamicSearchParams(expression: string) {
}
}
switch(workUnitStore.type){
switch(workUnitStore.type){
case'validation-client':
// TODO(instant-validation): in build, this depends on samples
* This function allows you to indicate that you require an actual user Request before continuing.
* This function allows you to indicate that you require an actual user Request before continuing.
...
@@ -84,6 +85,14 @@ export function connection(): Promise<void> {
...
@@ -84,6 +85,14 @@ export function connection(): Promise<void> {
workStore.route,
workStore.route,
'`connection()`'
'`connection()`'
)
)
case'validation-client':{
// TODO(NAR-789): make this consistent with the actual browser behavior when we change it.
// Until then, erroring is fine.
constexportName='`connection`'
thrownewInvariantError(
`${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`
)
}
case'prerender-ppr':
case'prerender-ppr':
// We use React's postpone API to interrupt rendering here to create a
// We use React's postpone API to interrupt rendering here to create a
// dynamic hole
// dynamic hole
...
@@ -124,5 +133,7 @@ export function connection(): Promise<void> {
...
@@ -124,5 +133,7 @@ export function connection(): Promise<void> {
}
}
// If we end up here, there was no work store or work unit store present.
// If we end up here, there was no work store or work unit store present.
// TODO(NAR-789): connection() is not currently statically prevented from being imported in client components,
// so we always error about a missing work unit store.
@@ -76,6 +76,7 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
...
@@ -76,6 +76,7 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
case'prerender':
case'prerender':
returnmakeHangingCookies(workStore,workUnitStore)
returnmakeHangingCookies(workStore,workUnitStore)
case'prerender-client':
case'prerender-client':
case'validation-client':
constexportName='`cookies`'
constexportName='`cookies`'
thrownewInvariantError(
thrownewInvariantError(
`${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`
`${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`
@@ -59,11 +59,17 @@ export function draftMode(): Promise<DraftMode> {
...
@@ -59,11 +59,17 @@ export function draftMode(): Promise<DraftMode> {
// Otherwise, we fall through to providing an empty draft mode.
// Otherwise, we fall through to providing an empty draft mode.
// eslint-disable-next-line no-fallthrough
// eslint-disable-next-line no-fallthrough
case'prerender':
case'prerender':
case'prerender-client':
case'prerender-ppr':
case'prerender-ppr':
case'prerender-legacy':
case'prerender-legacy':
// Return empty draft mode
// Return empty draft mode
returncreateOrGetCachedDraftMode(null,workStore)
returncreateOrGetCachedDraftMode(null,workStore)
case'prerender-client':
case'validation-client':{
constexportName='`draftMode`'
thrownewInvariantError(
`${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`
)
}
default:
default:
returnworkUnitStoresatisfiesnever
returnworkUnitStoresatisfiesnever
...
@@ -217,6 +223,7 @@ function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
...
@@ -217,6 +223,7 @@ function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
)
)
}
}
case'prerender-client':
case'prerender-client':
case'validation-client':
constexportName='`draftMode`'
constexportName='`draftMode`'
thrownewInvariantError(
thrownewInvariantError(
`${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`
`${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`
@@ -76,6 +76,7 @@ export function headers(): Promise<ReadonlyHeaders> {
...
@@ -76,6 +76,7 @@ export function headers(): Promise<ReadonlyHeaders> {
)
)
case'prerender':
case'prerender':
case'prerender-client':
case'prerender-client':
case'validation-client':
case'private-cache':
case'private-cache':
case'prerender-runtime':
case'prerender-runtime':
case'prerender-ppr':
case'prerender-ppr':
...
@@ -98,6 +99,7 @@ export function headers(): Promise<ReadonlyHeaders> {
...
@@ -98,6 +99,7 @@ export function headers(): Promise<ReadonlyHeaders> {
case'prerender':
case'prerender':
returnmakeHangingHeaders(workStore,workUnitStore)
returnmakeHangingHeaders(workStore,workUnitStore)
case'prerender-client':
case'prerender-client':
case'validation-client':
constexportName='`headers`'
constexportName='`headers`'
thrownewInvariantError(
thrownewInvariantError(
`${exportName} must not be used within a client component. Next.js should be preventing ${exportName} from being included in client components statically, but did not in this case.`
`${exportName} must not be used within a client component. Next.js should be preventing ${exportName} from being included in client components statically, but did not in this case.`
@@ -65,7 +65,6 @@ export function getRootParam(paramName: string): Promise<ParamValue> {
...
@@ -65,7 +65,6 @@ export function getRootParam(paramName: string): Promise<ParamValue> {
)
)
}
}
case'prerender':
case'prerender':
case'prerender-client':
case'prerender-ppr':
case'prerender-ppr':
case'prerender-legacy':{
case'prerender-legacy':{
returncreatePrerenderRootParamPromise(
returncreatePrerenderRootParamPromise(
...
@@ -75,6 +74,12 @@ export function getRootParam(paramName: string): Promise<ParamValue> {
...
@@ -75,6 +74,12 @@ export function getRootParam(paramName: string): Promise<ParamValue> {
apiName
apiName
)
)
}
}
case'validation-client':
case'prerender-client':{
thrownewInvariantError(
`${apiName} must not be used within a client component. Next.js should be preventing ${apiName} from being included in client components statically, but did not in this case.`
)
}
case'private-cache':
case'private-cache':
case'prerender-runtime':
case'prerender-runtime':
case'request':{
case'request':{
...
@@ -92,15 +97,13 @@ export function getRootParam(paramName: string): Promise<ParamValue> {
...
@@ -92,15 +97,13 @@ export function getRootParam(paramName: string): Promise<ParamValue> {
functioncreatePrerenderRootParamPromise(
functioncreatePrerenderRootParamPromise(
paramName:string,
paramName:string,
workStore:WorkStore,
workStore:WorkStore,
prerenderStore:StaticPrerenderStore,
prerenderStore:
|PrerenderStorePPR
|PrerenderStoreLegacy
|PrerenderStoreModernServer,
apiName:string
apiName:string
):Promise<ParamValue>{
):Promise<ParamValue>{
switch(prerenderStore.type){
switch(prerenderStore.type){
case'prerender-client':{
thrownewInvariantError(
`${apiName} must not be used within a client component. Next.js should be preventing ${apiName} from being included in client components statically, but did not in this case.`
`${expression} must not be used within a client component. Next.js should be preventing ${expression} from being allowed in client components statically, but did not in this case.`
`${expression} must not be used within a client component. Next.js should be preventing ${expression} from being allowed in client components statically, but did not in this case.`
)
)
...
@@ -998,6 +1000,7 @@ export async function cache(
...
@@ -998,6 +1000,7 @@ export async function cache(
}else{
}else{
switch(workUnitStore?.type){
switch(workUnitStore?.type){
case'prerender-client':
case'prerender-client':
case'validation-client':
constexpression='"use cache"'
constexpression='"use cache"'
thrownewInvariantError(
thrownewInvariantError(
`${expression} must not be used within a client component. Next.js should be preventing ${expression} from being allowed in client components statically, but did not in this case.`
`${expression} must not be used within a client component. Next.js should be preventing ${expression} from being allowed in client components statically, but did not in this case.`
...
@@ -1912,6 +1915,7 @@ function shouldForceRevalidate(
...
@@ -1912,6 +1915,7 @@ function shouldForceRevalidate(
case'prerender-runtime':
case'prerender-runtime':
case'prerender':
case'prerender':
case'prerender-client':
case'prerender-client':
case'validation-client':
case'prerender-ppr':
case'prerender-ppr':
case'prerender-legacy':
case'prerender-legacy':
case'unstable-cache':
case'unstable-cache':
...
@@ -1955,6 +1959,7 @@ function shouldDiscardCacheEntry(
...
@@ -1955,6 +1959,7 @@ function shouldDiscardCacheEntry(
`${expression} must not be used within a client component. Next.js should be preventing ${expression} from being included in client components statically, but did not in this case.`
`${expression} must not be used within a client component. Next.js should be preventing ${expression} from being included in client components statically, but did not in this case.`
// TODO(instant-validation) - this should be valid, but currently isn't
awaitwaitForNoErrorToast(browser)
// await waitForNoErrorToast(browser)
awaitexpect(browser).toDisplayCollapsedRedbox(`
[
{
"description": "Route "/suspense-in-root/static/valid-client-api-in-parent/sync-io": Could not validate \`unstable_instant\` because a Client Component in a parent segment prevented the page from rendering.",
"description": "Route "/suspense-in-root/static/valid-client-api-in-parent/sync-io": Could not validate \`unstable_instant\` because a Client Component in a parent segment prevented the page from rendering.",
// TODO(instant-validation) - this should be valid, but currently isn't
awaitwaitForNoErrorToast(browser)
// await waitForNoErrorToast(browser)
awaitexpect(browser).toDisplayCollapsedRedbox(`
{
"description": "Route "/suspense-in-root/static/valid-client-api-in-parent/dynamic-params/[id]": Could not validate \`unstable_instant\` because a Client Component in a parent segment prevented the page from rendering.",
// TODO(instant-validation) - this should be valid, but currently isn't
awaitwaitForNoErrorToast(browser)
// await waitForNoErrorToast(browser)
awaitexpect(browser).toDisplayCollapsedRedbox(`
{
"description": "Route "/suspense-in-root/static/valid-client-api-in-parent/search-params": Could not validate \`unstable_instant\` because a Client Component in a parent segment prevented the page from rendering.",