mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
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).
26 lines
424 B
TypeScript
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 />
|
|
}
|