Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
test(nextjs): Added nextjs CF workers test app#18928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
| # dependencies | ||
| /node_modules | ||
| /.pnp | ||
| .pnp.* | ||
| .yarn/* | ||
| !.yarn/patches | ||
| !.yarn/plugins | ||
| !.yarn/releases | ||
| !.yarn/versions | ||
| # testing | ||
| /coverage | ||
| # next.js | ||
| /.next/ | ||
| /out/ | ||
| # production | ||
| /build | ||
| # misc | ||
| .DS_Store | ||
| *.pem | ||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .pnpm-debug.log* | ||
| # env files (can opt-in for committing if needed) | ||
| .env* | ||
| # vercel | ||
| .vercel | ||
| # typescript | ||
| *.tsbuildinfo | ||
| next-env.d.ts | ||
| # Sentry Config File | ||
| .env.sentry-build-plugin |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @sentry:registry=http://127.0.0.1:4873 | ||
| @sentry-internal:registry=http://127.0.0.1:4873 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { PropsWithChildren } from 'react'; | ||
| export const dynamic = 'force-dynamic'; | ||
| export default function Layout({ children }: PropsWithChildren<{}>) { | ||
| return ( | ||
| <div> | ||
| <p>Layout</p> | ||
| {children} | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { PropsWithChildren } from 'react'; | ||
| export const dynamic = 'force-dynamic'; | ||
| export default function Layout({ children }: PropsWithChildren<{}>) { | ||
| return ( | ||
| <div> | ||
| <p>DynamicLayout</p> | ||
| {children} | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| export const dynamic = 'force-dynamic'; | ||
| export default async function Page() { | ||
| return ( | ||
| <div> | ||
| <p>Dynamic Page</p> | ||
| </div> | ||
| ); | ||
| } | ||
| export async function generateMetadata() { | ||
| return { | ||
| title: 'I am dynamic page generated metadata', | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { PropsWithChildren } from 'react'; | ||
| export const dynamic = 'force-dynamic'; | ||
| export default function Layout({ children }: PropsWithChildren<{}>) { | ||
| return ( | ||
| <div> | ||
| <p>Layout</p> | ||
| {children} | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export const dynamic = 'force-dynamic'; | ||
| export default function Page() { | ||
| return <p>Hello World!</p>; | ||
| } | ||
| export async function generateMetadata() { | ||
| return { | ||
| title: 'I am generated metadata', | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export function GET() { | ||
| return Response.json({ name: 'John Doe' }); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 'use client'; | ||
| import * as Sentry from '@sentry/nextjs'; | ||
| import NextError from 'next/error'; | ||
| import { useEffect } from 'react'; | ||
| export default function GlobalError({ error }: { error: Error & { digest?: string } }) { | ||
| useEffect(() => { | ||
| Sentry.captureException(error); | ||
| }, [error]); | ||
| return ( | ||
| <html> | ||
| <body> | ||
| {/* `NextError` is the default Next.js error page component. Its type | ||
| definition requires a `statusCode` prop. However, since the App Router | ||
| does not expose status codes for errors, we simply pass 0 to render a | ||
| generic error message. */} | ||
| <NextError statusCode={0} /> | ||
| </body> | ||
| </html> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| export const revalidate = 60; // ISR: revalidate every 60 seconds | ||
| export const dynamicParams = true; // Allow dynamic params beyond generateStaticParams | ||
| export async function generateStaticParams(): Promise<Array<{ product: string }>> { | ||
| return [{ product: 'laptop' }, { product: 'phone' }, { product: 'tablet' }]; | ||
| } | ||
| export default async function ISRProductPage({ params }: { params: Promise<{ product: string }> }) { | ||
| const { product } = await params; | ||
| return ( | ||
| <div> | ||
| <h1>ISR Product: {product}</h1> | ||
| <div id="isr-product-id">{product}</div> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| export const revalidate = 60; // ISR: revalidate every 60 seconds | ||
| export const dynamicParams = true; | ||
| export async function generateStaticParams(): Promise<never[]> { | ||
| return []; | ||
| } | ||
| export default function ISRStaticPage() { | ||
| return ( | ||
| <div> | ||
| <h1>ISR Static Page</h1> | ||
| <div id="isr-static-marker">static-isr</div> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export default function Layout({ children }: { children: React.ReactNode }) { | ||
| return ( | ||
| <html lang="en"> | ||
| <body>{children}</body> | ||
| </html> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| 'use client'; | ||
| import * as Sentry from '@sentry/nextjs'; | ||
| export default function Page() { | ||
| const handleClick = async () => { | ||
| Sentry.metrics.count('test.page.count', 1, { | ||
| attributes: { | ||
| page: '/metrics', | ||
| 'random.attribute': 'Apples', | ||
| }, | ||
| }); | ||
| Sentry.metrics.distribution('test.page.distribution', 100, { | ||
| attributes: { | ||
| page: '/metrics', | ||
| 'random.attribute': 'Manzanas', | ||
| }, | ||
| }); | ||
| Sentry.metrics.gauge('test.page.gauge', 200, { | ||
| attributes: { | ||
| page: '/metrics', | ||
| 'random.attribute': 'Mele', | ||
| }, | ||
| }); | ||
| await fetch('/metrics/route-handler'); | ||
| }; | ||
| return ( | ||
| <div> | ||
| <h1>Metrics page</h1> | ||
| <button onClick={handleClick}>Emit</button> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import * as Sentry from '@sentry/nextjs'; | ||
| export const GET = async () => { | ||
| Sentry.metrics.count('test.route.handler.count', 1, { | ||
| attributes: { | ||
| endpoint: '/metrics/route-handler', | ||
| 'random.attribute': 'Potatoes', | ||
| }, | ||
| }); | ||
| Sentry.metrics.distribution('test.route.handler.distribution', 100, { | ||
| attributes: { | ||
| endpoint: '/metrics/route-handler', | ||
| 'random.attribute': 'Patatas', | ||
| }, | ||
| }); | ||
| Sentry.metrics.gauge('test.route.handler.gauge', 200, { | ||
| attributes: { | ||
| endpoint: '/metrics/route-handler', | ||
| 'random.attribute': 'Patate', | ||
| }, | ||
| }); | ||
| return Response.json({ message: 'Bueno' }); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { Suspense } from 'react'; | ||
| export const dynamic = 'force-dynamic'; | ||
| export default async function Page() { | ||
| return ( | ||
| <Suspense fallback={<p>Loading...</p>}> | ||
| {/* @ts-ignore */} | ||
| <Crash />; | ||
| </Suspense> | ||
| ); | ||
| } | ||
| async function Crash() { | ||
| throw new Error('I am technically uncatchable'); | ||
| return <p>unreachable</p>; | ||
| } | ||
logaretm marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // No generateStaticParams - this is NOT an ISR page | ||
| export default async function NonISRPage({ params }: { params: Promise<{ item: string }> }) { | ||
| const { item } = await params; | ||
| return ( | ||
| <div> | ||
| <h1>Non-ISR Dynamic Page: {item}</h1> | ||
| <div id="non-isr-item-id">{item}</div> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function Page() { | ||
| return <p>Next 16 test app</p>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { PropsWithChildren } from 'react'; | ||
| export const dynamic = 'force-dynamic'; | ||
| export default async function Layout({ children }: PropsWithChildren<unknown>) { | ||
| await new Promise(resolve => setTimeout(resolve, 500)); | ||
| return <>{children}</>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export const dynamic = 'force-dynamic'; | ||
| export default async function Page() { | ||
| await new Promise(resolve => setTimeout(resolve, 1000)); | ||
| return <p>I am page 2</p>; | ||
| } | ||
| export async function generateMetadata() { | ||
| (await fetch('https://example.com/', { cache: 'no-store' })).text(); | ||
| return { | ||
| title: 'my title', | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function ParameterizedPage() { | ||
| return <div>Dynamic page two</div>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function BeepPage() { | ||
| return <div>Beep</div>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function ParameterizedPage() { | ||
| return <div>Dynamic page one</div>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function StaticPage() { | ||
| return <div>Static page</div>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import Link from 'next/link'; | ||
| export default function Page() { | ||
| return ( | ||
| <Link id="prefetch-link" href="/prefetching/to-be-prefetched"> | ||
| link | ||
| </Link> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export const dynamic = 'force-dynamic'; | ||
| export default function Page() { | ||
| return <p>Hello</p>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export default function RedirectDestinationPage() { | ||
| return ( | ||
| <div> | ||
| <h1>Redirect Destination</h1> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { redirect } from 'next/navigation'; | ||
| async function redirectAction() { | ||
| 'use server'; | ||
| redirect('/redirect/destination'); | ||
| } | ||
| export default function RedirectOriginPage() { | ||
| return ( | ||
| <> | ||
| {/* @ts-ignore */} | ||
logaretm marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| <form action={redirectAction}> | ||
| <button type="submit">Redirect me</button> | ||
| </form> | ||
| </> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { NextResponse } from 'next/server'; | ||
| export const runtime = 'edge'; | ||
| export const dynamic = 'force-dynamic'; | ||
| export async function GET() { | ||
| return NextResponse.json({ message: 'Hello Edge Route Handler' }); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { NextResponse } from 'next/server'; | ||
| export const dynamic = 'force-dynamic'; | ||
| export async function GET() { | ||
| return NextResponse.json({ message: 'Hello Node Route Handler' }); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| 'use client'; | ||
| import { use } from 'react'; | ||
| export function RenderPromise({ stringPromise }: { stringPromise: Promise<string> }) { | ||
| const s = use(stringPromise); | ||
| return <>{s}</>; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.