-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dynamicIO] wait for cache signal before validating
wait for caches to fill in dev before performing validation
- Loading branch information
Showing
11 changed files
with
314 additions
and
82 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
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
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
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
9 changes: 9 additions & 0 deletions
9
test/development/app-dir/dynamic-io-dev-cache-scope/app/api/data.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,9 @@ | ||
function delay() { | ||
return new Promise((resolve) => { | ||
setTimeout(resolve, 100) | ||
}) | ||
} | ||
export async function fetchData() { | ||
await delay() | ||
return '' + Math.random() | ||
} |
42 changes: 42 additions & 0 deletions
42
test/development/app-dir/dynamic-io-dev-cache-scope/app/cached/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,42 @@ | ||
import { | ||
revalidateTag, | ||
unstable_cacheLife as cacheLife, | ||
unstable_cacheTag, | ||
} from 'next/cache' | ||
import { fetchData } from '../api/data' | ||
// import { Suspense } from 'react' | ||
// import { cookies, headers } from 'next/headers' | ||
|
||
function InnerComponent({ children }) { | ||
return <span id="value">{children}</span> | ||
} | ||
|
||
async function refresh() { | ||
'use server' | ||
revalidateTag('hello') | ||
} | ||
|
||
async function reload() { | ||
'use server' | ||
} | ||
|
||
async function Component() { | ||
'use cache' | ||
cacheLife({ revalidate: 6 }) | ||
unstable_cacheTag('hello') | ||
return <InnerComponent>{await fetchData()}</InnerComponent> | ||
} | ||
|
||
export default async function Home() { | ||
return ( | ||
<> | ||
<form action={refresh}> | ||
<button id="refresh">Refresh</button> | ||
</form> | ||
<form action={reload}> | ||
<button id="reload">Reload</button> | ||
</form> | ||
<Component /> | ||
</> | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
test/development/app-dir/dynamic-io-dev-cache-scope/app/layout.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,9 @@ | ||
export default function Root({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html> | ||
<body> | ||
<main>{children}</main> | ||
</body> | ||
</html> | ||
) | ||
} |
33 changes: 33 additions & 0 deletions
33
test/development/app-dir/dynamic-io-dev-cache-scope/app/uncached/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,33 @@ | ||
import { fetchData } from '../api/data' | ||
// import { Suspense } from 'react' | ||
// import { cookies, headers } from 'next/headers' | ||
|
||
function InnerComponent({ children }) { | ||
return <span id="value">{children}</span> | ||
} | ||
|
||
async function refresh() { | ||
'use server' | ||
} | ||
|
||
async function reload() { | ||
'use server' | ||
} | ||
|
||
async function Component() { | ||
return <InnerComponent>{await fetchData()}</InnerComponent> | ||
} | ||
|
||
export default async function Home() { | ||
return ( | ||
<> | ||
<form action={refresh}> | ||
<button id="refresh">Refresh</button> | ||
</form> | ||
<form action={reload}> | ||
<button id="reload">Reload</button> | ||
</form> | ||
<Component /> | ||
</> | ||
) | ||
} |
Oops, something went wrong.