mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
With Cache Components enabled in development, fetches without an explicit cache config were incorrectly routed through `createCachedPrerenderResponse` during the cache filling phase due to the `serverComponentsHmrCache` condition. This function awaits the entire response before returning to the caller, which prevents infinitely streaming responses from ever being read or aborted. This is a regression that was introduced in #84088. These fetches should be treated as dynamic and use `createCachedDynamicResponse` instead, which returns immediately and caches in the background with proper error handling. The fix adds `isCacheableRevalidate` to the condition so only explicitly cacheable fetches use the blocking path. Additionally, the "Failed to set fetch cache" warning is now suppressed when the request's abort signal was triggered, since aborting is intentional.
20 lines
443 B
TypeScript
20 lines
443 B
TypeScript
async function fetchChunk() {
|
|
const controller = new AbortController()
|
|
|
|
const response = await fetch(`http://localhost:${process.env.PORT}/api/sse`, {
|
|
signal: controller.signal,
|
|
})
|
|
|
|
const reader = response.body!.getReader()
|
|
const { value } = await reader.read()
|
|
controller.abort()
|
|
|
|
return new TextDecoder().decode(value)
|
|
}
|
|
|
|
export default async function Page() {
|
|
const chunk = await fetchChunk()
|
|
|
|
return <p>{chunk}</p>
|
|
}
|