-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix fetch lock not being consistently released (#75028)
- Loading branch information
Showing
4 changed files
with
190 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/e2e/app-dir/app-fetch-deduping-errors/app-fetch-deduping-errors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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') | ||
}) | ||
}) |
45 changes: 45 additions & 0 deletions
45
test/e2e/app-dir/app-fetch-deduping-errors/app/[id]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'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> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<title>my static site</title> | ||
</head> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |