diff --git a/packages/next/src/server/app-render/app-render.tsx b/packages/next/src/server/app-render/app-render.tsx index 43181b9dcf8f99..2bcf05577a0990 100644 --- a/packages/next/src/server/app-render/app-render.tsx +++ b/packages/next/src/server/app-render/app-render.tsx @@ -1038,6 +1038,17 @@ async function renderToHTMLOrFlightImpl( pageName: renderOpts.page, }) + console.log( + 'createServerModuleMap', + serverActionsManifest.node, + renderOpts.page, + serverModuleMap + ) + + console.log( + (serverModuleMap as any)['b050014aa80bf8788052fb3c144178ac2925558c'] + ) + setReferenceManifestsSingleton({ clientReferenceManifest, serverActionsManifest, diff --git a/packages/next/src/server/app-render/encryption-utils.ts b/packages/next/src/server/app-render/encryption-utils.ts index 7a59dbf0ace633..576dc7fc550d0f 100644 --- a/packages/next/src/server/app-render/encryption-utils.ts +++ b/packages/next/src/server/app-render/encryption-utils.ts @@ -78,6 +78,7 @@ export function setReferenceManifestsSingleton({ } } }) { + console.log('set singleton', new Error().stack) // @ts-ignore globalThis[SERVER_ACTION_MANIFESTS_SINGLETON] = { clientReferenceManifest, diff --git a/packages/next/src/server/use-cache/use-cache-wrapper.ts b/packages/next/src/server/use-cache/use-cache-wrapper.ts index 94864d188f7e01..2ddd04f0a97098 100644 --- a/packages/next/src/server/use-cache/use-cache-wrapper.ts +++ b/packages/next/src/server/use-cache/use-cache-wrapper.ts @@ -679,10 +679,22 @@ export function cache(kind: string, id: string, fn: any) { moduleMap: isEdgeRuntime ? clientReferenceManifest.edgeRscModuleMapping : clientReferenceManifest.rscModuleMapping, - serverModuleMap: null, + serverModuleMap: getServerModuleMap(), } - return createFromReadableStream(stream, { + const [s, s2] = stream.tee() + + for await (let x of s2) { + console.log(Buffer.from(x).toString('utf8')) + } + + console.log( + serverConsumerManifest.serverModuleMap[ + 'b050014aa80bf8788052fb3c144178ac2925558c' + ] + ) + + return createFromReadableStream(s, { serverConsumerManifest, temporaryReferences, replayConsoleLogs, diff --git a/test/e2e/app-dir/use-cache/app/form/page.tsx b/test/e2e/app-dir/use-cache/app/form/page.tsx new file mode 100644 index 00000000000000..4bb8554147a967 --- /dev/null +++ b/test/e2e/app-dir/use-cache/app/form/page.tsx @@ -0,0 +1,34 @@ +import { revalidateTag, unstable_cacheTag as cacheTag } from 'next/cache' + +async function refresh() { + 'use server' + revalidateTag('home') +} + +async function Page() { + 'use cache' + cacheTag('home') + + console.log(refresh.toString()) + + return { + refresh, + children: ( +
+ +

{Date.now()}

+
+ ), + } +} + +export default async function () { + const result = (await Page()).refresh + console.log( + result.toString(), + (result as any).$$typeof, + (result as any).$$id, + (result as any).bind.toString() + ) + return result +}