Files
Hendrik LiebauandGitHub 33dc0f2f90 Error handling for hanging promises in "use cache" closures (#74750)
Based on #74652, this adds error handling for `"use cache"` closures
that use closed-over hanging promises. It uses a similar technique to
encode the hanging promises into the serialized bound arguments string.
In addition, we need to notify the cache signal when decrypting the
bound args, since this operation does not resolve in the current task.
This is now the same behavior as for encrypting the bound args (see
#73521).
2025-01-23 00:38:10 +01:00

26 lines
424 B
TypeScript

import { connection } from 'next/server'
import React from 'react'
async function fetchUncachedData() {
await connection()
return Math.random()
}
export default async function Page() {
const uncachedDataPromise = fetchUncachedData()
const Foo = async () => {
'use cache'
return (
<>
<p>{await uncachedDataPromise}</p>
<p>{Math.random()}</p>
</>
)
}
return <Foo />
}