"730":"Dynamic imports should not be instrumented in the edge runtime, because `cacheComponents` doesn't support it",
"730":"Dynamic imports should not be instrumented in the edge runtime, because `cacheComponents` doesn't support it",
"731":"chainStreams requires at least one stream",
"731":"chainStreams requires at least one stream",
"732":"dynamic responses cannot be unchunked. This is a bug in Next.js",
"732":"dynamic responses cannot be unchunked. This is a bug in Next.js",
"733":"null responses cannot be unchunked"
"733":"null responses cannot be unchunked",
"734":"createPrerenderParamsForClientSegment should not be called in cache contexts.",
"735":"%s must not be used within \"use cache\". It can only be nested inside of another %s.",
"736":"createParamsFromClient should not be called in cache contexts.",
"737":"Unexpected work unit store.",
"738":"createServerParamsForRoute should not be called in cache contexts.",
"739":"createSearchParamsFromClient should not be called in cache contexts.",
"740":"createServerPathnameForMetadata should not be called in cache contexts.",
"741":"%s must not be used within a client component. Next.js should be preventing %s from being allowed in client components statically, but did not in this case.",
"742":"Route %s used \"headers\" inside \"use cache: private\". Accessing \"headers\" inside a private cache scope is not supported. If you need this data inside a cached function use \"headers\" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"743":"createServerParamsForServerSegment should not be called in cache contexts.",
"744":"%s must not be used within \\`unstable_cache()\\`.",
"745":"\\`%s\\` was called inside a cache scope. Next.js should be preventing %s from being included in server components statically, but did not in this case.",
"746":"createPrerenderSearchParamsForClientPage should not be called in cache contexts.",
"747":"createServerSearchParamsForServerPage should not be called in cache contexts.",
"748":"cacheLifeProfiles should always be provided.",
"749":"A private cache entry must not be retrieved from the cache handler.",
"750":"A default cacheLife profile must always be provided.",
"751":"%s cannot not be used outside of a request context.",
"752":"Route %s used \"connection\" inside \"use cache\". The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual request, but caches must be able to be produced before a request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"753":"Route %s used \"connection\" inside \"use cache: private\". The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual navigation request, but caches must be able to be produced before a navigation request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"754":"%s cannot be used outside of a request context."
@@ -592,8 +600,12 @@ export function useDynamicRouteParams(expression: string) {
...
@@ -592,8 +600,12 @@ export function useDynamicRouteParams(expression: string) {
workStore,
workStore,
workUnitStore
workUnitStore
)
)
case'request':
case'cache':
case'cache':
case'private-cache':
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.`
@@ -43,10 +43,25 @@ export function connection(): Promise<void> {
...
@@ -43,10 +43,25 @@ export function connection(): Promise<void> {
if(workUnitStore){
if(workUnitStore){
switch(workUnitStore.type){
switch(workUnitStore.type){
case'cache':
case'cache':{
thrownewError(
consterror=newError(
`Route ${workStore.route} used "connection" inside "use cache". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
`Route ${workStore.route} used "connection" inside "use cache". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual request, but caches must be able to be produced before a request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
)
Error.captureStackTrace(error,connection)
workStore.invalidDynamicUsageError??=error
throwerror
}
case'private-cache':{
// It might not be intuitive to throw for private caches as well, but
// we don't consider dynamic prefetches as "actual requests" (in the
// navigation sense), despite allowing them to read cookies.
consterror=newError(
`Route ${workStore.route} used "connection" inside "use cache: private". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual navigation request, but caches must be able to be produced before a navigation request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
)
)
Error.captureStackTrace(error,connection)
workStore.invalidDynamicUsageError??=error
throwerror
}
case'unstable-cache':
case'unstable-cache':
thrownewError(
thrownewError(
`Route ${workStore.route} used "connection" inside a function cached with "unstable_cache(...)". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`
`Route ${workStore.route} used "connection" inside a function cached with "unstable_cache(...)". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`
@@ -307,7 +309,8 @@ function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
...
@@ -307,7 +309,8 @@ function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
if(workUnitStore){
if(workUnitStore){
switch(workUnitStore.type){
switch(workUnitStore.type){
case'cache':{
case'cache':
case'private-cache':{
consterror=newError(
consterror=newError(
`Route ${workStore.route} used "${expression}" inside "use cache". The enabled status of draftMode can be read in caches but you must not enable or disable draftMode inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
`Route ${workStore.route} used "${expression}" inside "use cache". The enabled status of draftMode can be read in caches but you must not enable or disable draftMode inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
@@ -79,13 +79,22 @@ export function headers(): Promise<ReadonlyHeaders> {
...
@@ -79,13 +79,22 @@ export function headers(): Promise<ReadonlyHeaders> {
if(workUnitStore){
if(workUnitStore){
switch(workUnitStore.type){
switch(workUnitStore.type){
case'cache':
case'cache':{
consterror=newError(
consterror=newError(
`Route ${workStore.route} used "headers" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
`Route ${workStore.route} used "headers" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
)
)
Error.captureStackTrace(error,headers)
Error.captureStackTrace(error,headers)
workStore.invalidDynamicUsageError??=error
workStore.invalidDynamicUsageError??=error
throwerror
throwerror
}
case'private-cache':{
consterror=newError(
`Route ${workStore.route} used "headers" inside "use cache: private". Accessing "headers" inside a private cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
)
Error.captureStackTrace(error,headers)
workStore.invalidDynamicUsageError??=error
throwerror
}
case'unstable-cache':
case'unstable-cache':
thrownewError(
thrownewError(
`Route ${workStore.route} used "headers" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`
`Route ${workStore.route} used "headers" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`
@@ -39,8 +39,9 @@ export async function unstable_rootParams(): Promise<Params> {
...
@@ -39,8 +39,9 @@ export async function unstable_rootParams(): Promise<Params> {
}
}
switch(workUnitStore.type){
switch(workUnitStore.type){
case'unstable-cache':
case'cache':
case'cache':{
case'private-cache':
case'unstable-cache':{
thrownewError(
thrownewError(
`Route ${workStore.route} used \`unstable_rootParams()\` inside \`"use cache"\` or \`unstable_cache\`. Support for this API inside cache scopes is planned for a future version of Next.js.`
`Route ${workStore.route} used \`unstable_rootParams()\` inside \`"use cache"\` or \`unstable_cache\`. Support for this API inside cache scopes is planned for a future version of Next.js.`
// TODO: Should we allow reading cookies and search params from the
// request for private caches in route handlers?
thrownewError(
thrownewError(
`Route ${store.route} used "${expression}" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
`Route ${store.route} used "${expression}" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
@@ -101,6 +101,7 @@ function revalidate(tags: string[], expression: string) {
...
@@ -101,6 +101,7 @@ function revalidate(tags: string[], expression: string) {
switch(workUnitStore.type){
switch(workUnitStore.type){
case'cache':
case'cache':
case'private-cache':
thrownewError(
thrownewError(
`Route ${store.route} used "${expression}" inside a "use cache" which is unsupported. To ensure revalidation is performed consistently it must always happen outside of renders and cached functions. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`
`Route ${store.route} used "${expression}" inside a "use cache" which is unsupported. To ensure revalidation is performed consistently it must always happen outside of renders and cached functions. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`