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