Unverified Commit 94bda499 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

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
parent 832c77d0
This diff is collapsed.
import { nextTestSetup } from 'e2e-utils'
describe('app-fetch-errors', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should still successfully render when a fetch request that acquires a cache lock errors', async () => {
const browser = await next.browser('/1')
expect(await browser.elementByCss('body').text()).toBe('Hello World 1')
})
})
'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>
}
export default function Layout({ children }) {
return (
<html lang="en">
<head>
<title>my static site</title>
</head>
<body>{children}</body>
</html>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment