Files
next.js/test/e2e/app-dir/app-fetch-deduping-errors/app/[id]/page.tsx
Zack TannerandGitHub 94bda4995e fix fetch lock not being consistently released (#74623)
When we acquire a lock on a fetch, and the fetch errors, we weren't
resolving the lock. This meant a subsequent request would stall waiting
to acquire a lock and prevent the page from rendering.

An example of this is a fetch with force-cache in `generateMetadata` and
another in the RSC where both requests encounter a fetch error.

Fixes #74613
2025-01-07 19:38:07 -08:00

46 lines
781 B
TypeScript

'use server'
import { Metadata } from 'next'
export async function generateMetadata({
params,
}: {
params: Promise<{ id: string }>
}): Promise<Metadata> {
const { id } = await params
try {
// this fetch request will error
await fetch('http://localhost:8000', {
cache: 'force-cache',
next: { tags: ['id'] },
})
} catch (err) {
console.log(err)
}
return {
title: id,
}
}
export default async function Error({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = await params
try {
// this fetch request will error
await fetch('http://localhost:8000', {
cache: 'force-cache',
next: { tags: ['id'] },
})
} catch (err) {
console.log(err)
}
return <div>Hello World {id}</div>
}