-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[next] ensure action outputs are created for edge functions (#11568)
Since we're rewriting `next-action` requests to `.action` outputs, we need to ensure that we also duplicate the edge function handler for it. This runs all of the existing Node runtime tests in the Edge runtime as well. However, there's a discrepancy in how `x-vercel-cache` is returned, so for now we instead validate that its responding with `x-edge-runtime`.
- Loading branch information
Showing
16 changed files
with
372 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@vercel/next': patch | ||
--- | ||
|
||
ensure `.action` outputs are created for edge functions |
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
19 changes: 19 additions & 0 deletions
19
...t/fixtures/00-app-dir-actions-experimental-streaming/app/edge/client/dynamic/[id]/page.js
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,19 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import { increment } from '../../../../actions'; | ||
|
||
export default function Page() { | ||
const [count, setCount] = useState(0); | ||
async function updateCount() { | ||
const newCount = await increment(count); | ||
setCount(newCount); | ||
} | ||
|
||
return ( | ||
<form action={updateCount}> | ||
<div id="count">{count}</div> | ||
<button>Submit</button> | ||
</form> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
...test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/client/dynamic/layout.js
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,5 @@ | ||
export const dynamic = 'force-dynamic'; | ||
|
||
export default function Layout({ children }) { | ||
return children; | ||
} |
19 changes: 19 additions & 0 deletions
19
...00-app-dir-actions-experimental-streaming/app/edge/client/static/[dynamic-static]/page.js
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,19 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import { increment } from '../../../../actions'; | ||
|
||
export default function Page() { | ||
const [count, setCount] = useState(0); | ||
async function updateCount() { | ||
const newCount = await increment(count); | ||
setCount(newCount); | ||
} | ||
|
||
return ( | ||
<form action={updateCount}> | ||
<div id="count">{count}</div> | ||
<button>Submit</button> | ||
</form> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
.../test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/client/static/layout.js
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,5 @@ | ||
export const dynamic = 'force-static'; | ||
|
||
export default function Layout({ children }) { | ||
return children; | ||
} |
19 changes: 19 additions & 0 deletions
19
...xt/test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/client/static/page.js
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,19 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import { increment } from '../../../actions'; | ||
|
||
export default function Page() { | ||
const [count, setCount] = useState(0); | ||
async function updateCount() { | ||
const newCount = await increment(count); | ||
setCount(newCount); | ||
} | ||
|
||
return ( | ||
<form action={updateCount}> | ||
<div id="count">{count}</div> | ||
<button>Submit</button> | ||
</form> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/next/test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/layout.js
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,5 @@ | ||
export const runtime = 'edge'; | ||
|
||
export default function Layout({ children }) { | ||
return <div>{children}</div>; | ||
} |
45 changes: 45 additions & 0 deletions
45
packages/next/test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/other/page.js
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 client'; | ||
|
||
// @ts-ignore | ||
import { useCallback, useState } from 'react'; | ||
|
||
function request(method) { | ||
return fetch('/api/test', { | ||
method, | ||
headers: { | ||
'content-type': 'multipart/form-data;.*', | ||
}, | ||
}); | ||
} | ||
|
||
export default function Home() { | ||
const [result, setResult] = useState('Press submit'); | ||
const onClick = useCallback(async method => { | ||
const res = await request(method); | ||
const text = await res.text(); | ||
|
||
setResult(res.ok ? `${method} ${text}` : 'Error: ' + res.status); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<div className="flex flex-col items-center justify-center h-screen"> | ||
<div className="flex flex-row space-x-2 items-center justify-center"> | ||
<button | ||
className="border border-white rounded-sm p-4 mb-4" | ||
onClick={() => onClick('GET')} | ||
> | ||
Submit GET | ||
</button> | ||
<button | ||
className="border border-white rounded-sm p-4 mb-4" | ||
onClick={() => onClick('POST')} | ||
> | ||
Submit POST | ||
</button> | ||
</div> | ||
<div className="text-white">{result}</div> | ||
</div> | ||
</> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
...xt/test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/rsc/dynamic/layout.js
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,5 @@ | ||
export const dynamic = 'force-dynamic'; | ||
|
||
export default function Layout({ children }) { | ||
return children; | ||
} |
15 changes: 15 additions & 0 deletions
15
...next/test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/rsc/dynamic/page.js
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,15 @@ | ||
import { revalidatePath } from 'next/cache'; | ||
|
||
export default async function Page() { | ||
async function serverAction() { | ||
'use server'; | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
revalidatePath('/dynamic'); | ||
} | ||
|
||
return ( | ||
<form action={serverAction}> | ||
<button>Submit</button> | ||
</form> | ||
); | ||
} |
15 changes: 15 additions & 0 deletions
15
...es/00-app-dir-actions-experimental-streaming/app/edge/rsc/static/[dynamic-static]/page.js
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,15 @@ | ||
import { revalidatePath } from 'next/cache'; | ||
|
||
export default async function Page() { | ||
async function serverAction() { | ||
'use server'; | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
revalidatePath('/dynamic'); | ||
} | ||
|
||
return ( | ||
<form action={serverAction}> | ||
<button>Submit</button> | ||
</form> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
...-actions-experimental-streaming/app/edge/rsc/static/generate-static-params/[slug]/page.js
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,19 @@ | ||
import { revalidatePath } from 'next/cache'; | ||
|
||
export default async function Page() { | ||
async function serverAction() { | ||
'use server'; | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
revalidatePath('/dynamic'); | ||
} | ||
|
||
return ( | ||
<form action={serverAction}> | ||
<button>Submit</button> | ||
</form> | ||
); | ||
} | ||
|
||
export function generateStaticParams() { | ||
return [{ slug: 'pre-generated' }]; | ||
} |
5 changes: 5 additions & 0 deletions
5
...ext/test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/rsc/static/layout.js
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,5 @@ | ||
export const dynamic = 'force-static'; | ||
|
||
export default function Layout({ children }) { | ||
return children; | ||
} |
15 changes: 15 additions & 0 deletions
15
.../next/test/fixtures/00-app-dir-actions-experimental-streaming/app/edge/rsc/static/page.js
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,15 @@ | ||
import { revalidatePath } from 'next/cache' | ||
|
||
export default async function Page() { | ||
async function serverAction() { | ||
'use server'; | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
revalidatePath('/dynamic'); | ||
} | ||
|
||
return ( | ||
<form action={serverAction}> | ||
<button>Submit</button> | ||
</form> | ||
); | ||
} |
Oops, something went wrong.