first commit
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled

This commit is contained in:
Arian Tron
2026-03-10 19:37:31 +03:30
commit 61f56f997c
27684 changed files with 2784175 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html>
<body>{children}</body>
</html>
)
}

View File

@@ -0,0 +1,3 @@
export default function Loading() {
return <div id="loading">loading...</div>
}

View File

@@ -0,0 +1,31 @@
'use server'
import { cookies } from 'next/headers'
import { refresh } from 'next/cache'
import { redirect } from 'next/navigation'
export async function addTodoEntry(entry: string) {
// simulate some latency
await new Promise((resolve) => setTimeout(resolve, 500))
const cookieStore = await cookies()
const existing = cookieStore.get('todo-entries')?.value || '[]'
const entries = JSON.parse(existing)
entries.push(entry)
cookieStore.set('todo-entries', JSON.stringify(entries))
}
export async function getTodoEntries() {
const cookieStore = await cookies()
const existing = cookieStore.get('todo-entries')?.value || '[]'
return JSON.parse(existing) as string[]
}
export async function addEntryAndRefresh(formData: FormData) {
const entry = formData.get('entry') as string
await addTodoEntry(entry)
refresh()
redirect('/redirect-and-refresh/foo')
}

View File

@@ -0,0 +1,3 @@
export default function Foo() {
return <div id="foo-page">Hello from Foo</div>
}

View File

@@ -0,0 +1,19 @@
import { getTodoEntries } from './actions'
export default async function Layout({ children }) {
const entries = await getTodoEntries()
console.log({ entries })
return (
<div>
<div id="todo-entries">
{entries.length > 0 ? (
entries.map((phrase, index) => <div key={index}>{phrase}</div>)
) : (
<div id="no-entries">No entries</div>
)}
</div>
<div>{children}</div>
</div>
)
}

View File

@@ -0,0 +1,20 @@
import { addEntryAndRefresh } from './actions'
export default function Page() {
return (
<>
<form action={addEntryAndRefresh}>
<label htmlFor="todo-input">Entry</label>
<input
id="todo-input"
type="text"
name="entry"
placeholder="Enter a new entry"
/>
<button id="add-button" type="submit">
Add New Todo Entry
</button>
</form>
</>
)
}

View File

@@ -0,0 +1,13 @@
import { connection } from 'next/server'
import { unstable_cache, refresh } from 'next/cache'
const cachedFunction = unstable_cache(async () => {
refresh()
return 'data'
}, ['test-key'])
export default async function Page() {
await connection()
const data = await cachedFunction()
return <div>{data}</div>
}

View File

@@ -0,0 +1,9 @@
import { connection } from 'next/server'
import { refresh } from 'next/cache'
export default async function Page() {
await connection()
refresh()
return <div>This should error</div>
}

View File

@@ -0,0 +1,8 @@
import { refresh } from 'next/cache'
import { connection } from 'next/server'
export async function GET() {
await connection()
refresh()
return new Response('ok')
}

View File

@@ -0,0 +1,6 @@
'use server'
import { refresh } from 'next/cache'
export async function triggerRefresh() {
refresh()
}

View File

@@ -0,0 +1,19 @@
import { triggerRefresh } from './actions'
import { connection } from 'next/server'
export default async function Page() {
await connection()
const timestamp = performance.now()
return (
<>
<div id="server-timestamp">{timestamp}</div>
<form action={triggerRefresh}>
<button id="refresh-button" type="submit">
Refresh
</button>
</form>
</>
)
}

View File

@@ -0,0 +1,3 @@
module.exports = {
cacheComponents: true,
}

View File

@@ -0,0 +1,103 @@
import { nextTestSetup } from 'e2e-utils'
import { retry, waitForRedbox, getRedboxDescription } from 'next-test-utils'
describe('app-dir refresh', () => {
const { next, skipped, isNextDev } = nextTestSetup({
files: __dirname,
// We do not have access to runtime logs when deployed
skipDeployment: true,
})
if (skipped) return
it('should refresh client cache when refresh() is called in a server action', async () => {
const browser = await next.browser('/refresh')
const initialServerTimestamp = await browser
.elementById('server-timestamp')
.text()
expect(initialServerTimestamp).toBeTruthy()
await new Promise((resolve) => setTimeout(resolve, 100))
await browser.elementById('refresh-button').click()
await retry(async () => {
const newServerTimestamp = await browser
.elementById('server-timestamp')
.text()
expect(newServerTimestamp).not.toBe(initialServerTimestamp)
expect(Number(newServerTimestamp)).toBeGreaterThan(
Number(initialServerTimestamp)
)
})
})
it('should throw an error when refresh() is called during page render', async () => {
const browser = await next.browser('/refresh-invalid-render')
if (isNextDev) {
await waitForRedbox(browser)
const description = await getRedboxDescription(browser)
expect(description).toContain(
'refresh can only be called from within a Server Action'
)
} else {
await retry(async () => {
expect(next.cliOutput).toContain(
'refresh can only be called from within a Server Action'
)
})
}
})
it('should throw an error when refresh() is called in a route handler', async () => {
const res = await next.fetch('/refresh-invalid-route')
expect(res.status).toBe(500)
await retry(async () => {
expect(next.cliOutput).toContain(
'refresh can only be called from within a Server Action'
)
})
})
it('should throw an error when refresh() is called in unstable_cache', async () => {
const browser = await next.browser('/refresh-invalid-cache')
if (isNextDev) {
await waitForRedbox(browser)
const description = await getRedboxDescription(browser)
expect(description).toContain(
'refresh can only be called from within a Server Action'
)
} else {
await retry(async () => {
expect(next.cliOutput).toContain(
'refresh can only be called from within a Server Action'
)
})
}
})
it('should let you read your write after a redirect and refresh', async () => {
const browser = await next.browser('/redirect-and-refresh')
const todoEntries = await browser.elementById('todo-entries').text()
expect(todoEntries).toBe('No entries')
const todoInput = await browser.elementById('todo-input')
await todoInput.fill('foo')
await browser.elementById('add-button').click()
await retry(async () => {
const newTodoEntries = await browser.elementById('todo-entries').text()
expect(newTodoEntries).toContain('foo')
})
expect(await browser.hasElementByCssSelector('#foo-page')).toBe(true)
expect(await browser.url()).toContain('/redirect-and-refresh/foo')
})
})