Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Oct 20, 2024
1 parent 7dc8574 commit 9d981ed
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/app-render/encryption-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function setReferenceManifestsSingleton({
}
}
}) {
console.log('set singleton', new Error().stack)
// @ts-ignore
globalThis[SERVER_ACTION_MANIFESTS_SINGLETON] = {
clientReferenceManifest,
Expand Down
16 changes: 14 additions & 2 deletions packages/next/src/server/use-cache/use-cache-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 34 additions & 0 deletions test/e2e/app-dir/use-cache/app/form/page.tsx
Original file line number Diff line number Diff line change
@@ -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: (
<form action={refresh}>
<button id="refresh">Refresh</button>
<p id="t">{Date.now()}</p>
</form>
),
}
}

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
}

0 comments on commit 9d981ed

Please sign in to comment.