Files
Josh StoryandGitHub 656271b210 [use-cache] track cache read earlier when encrypting bound args (#81427)
bound args need to be encrypted for use cache functions and currently we
track the read slightly later than will be necessary when we sync the
latest React. This change moves the tracking to be as early as possible
(as soon as the input signal is aborted or when the bound args are
finished being serialized, whichever is first).
2025-07-08 11:37:34 -07:00

27 lines
479 B
TypeScript

import React from 'react'
import { setTimeout } from 'timers/promises'
async function getUncachedData() {
await setTimeout(0)
return Math.random()
}
const getCachedData = async (promise: Promise<number>) => {
'use cache'
return await promise
}
async function indirection(promise: Promise<number>) {
'use cache'
return getCachedData(promise)
}
export default async function Page() {
const data = await indirection(getUncachedData())
return <p>{data}</p>
}