0

I have NextJS 13 application and trying to deploy to docker via GitHub Actions

And I use server component and doing some ec2 actions but I got error when I deployed to GitHub

31 550.4 > Build error occurred
#31 550.4 Error: Collecting page data for [object Object] is still timing out after 2 attempts. See more info here https://nextjs.org/docs/messages/page-data-collection-timeout
#31 550.4     at onRestart (/app/node_modules/next/dist/build/index.js:701:39)
#31 550.4     at Worker.isPageStatic (/app/node_modules/next/dist/lib/worker.js:88:40)
#31 550.4     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
#31 550.4     at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:103:20)
#31 550.4     at async /app/node_modules/next/dist/build/index.js:861:56
#31 550.4     at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:103:20)
#31 550.4     at async Promise.all (index 4)
#31 550.4     at async /app/node_modules/next/dist/build/index.js:796:17
#31 550.4     at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:103:20)
#31 550.4     at async /app/node_modules/next/dist/build/index.js:735:129
#31 550.4     at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:103:20)
#31 550.4     at async build (/app/node_modules/next/dist/build/index.js:145:29)

I think this is because next trying to calling ec2 action on build time how can I resolve this issue?

My Code:

import {getServerSession} from "next-auth";
import {authOptions} from "@/app/nextAuth";
import {redirect} from "next/navigation";
import {getInstanceStatus, startInstance, stopInstance} from "@/app/ec2";
import {StartInstanceButton, StopInstanceButton} from "@/components/instanceButtons";
import {JSX} from "react";

export default async function Home() {

    const session = await getServerSession(authOptions)

    if (!session) {
        redirect("/api/auth/signin")
    }

    let component: JSX.Element

    const status = await getInstanceStatus()

    switch (status) {
        case "running":
            component = <StopInstanceButton stop={stopInstance}/>
            break
        case "stopped":
        case "terminated":
            component = <StartInstanceButton start={startInstance}/>
            break
        case null:
            component = <h1 className="text-danger-500 font-bold text-2xl">failed</h1>
            break
        default:
            component = <h1 className="text-success-500 font-bold text-2xl">failed: {status}</h1>
            break
    }

    return <main className="flex flex-col items-center justify-center h-screen">
        {component}
    </main>
}
이동헌
  • 41
  • 1
  • 1

0 Answers0