Next.js Discord

Discord Forum

Webpage buggy, while vercel is building and after

Unanswered
Grass carp posted this in #help-forum
Open in Discord
Grass carpOP
When I upload my update to vercel, it sometimes is in the building time very buggy, and sometimes pages wont load:
I added an ErrorBoundary and got this Message:
ErrorMessage: Node.appendChild: Cannot have more than one Element child of a Document global-error-3e34c1730c5fcb05.js:1:232
ErrorStack: e@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:82810
e@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:82939
aZ@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:82990
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76998
aY@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76867
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:77127
aY@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76867
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76992
aY@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76867
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76992
aY@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76867
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76992
aY@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76867
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76992
aY@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76867
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76992
aY@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76867
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:82258
aY@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:76867
aG@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:80004
9153/u4/<@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:104845
u4@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:106622
n4@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:37293
9153/u4/<@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:106614
u4@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:106622
uQ@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:91525
uU@https://www.presnx.com/_next/static/chunks/b7dfe19b-d4b88bfc5f50d4b4.js:9:90699
E@https://www.presnx.com/_next/static/chunks/123-347907a40f51f832.js:25:1399
M@https://www.presnx.com/_next/static/chunks/123-347907a40f51f832.js:25:1951
global-error-3e34c1730c5fcb05.js:1:280
ErrorName: HierarchyRequestError global-error-3e34c1730c5fcb05.js:1:324
ErrorCause: undefined

1 Reply

Grass carpOP
Code:

interface PresentationInfos {
    images: string[],
    title: string,
    description: string,
    tags: string[],
    username: string,
    profilePic: string,
    grade: number
}

async function getSession(cookie: string): Promise<Session> {
    const response = await fetch(`${process.env.BASE_URL}/api/auth/session`, {
      headers: {
        cookie,
      },
    });
  
    const session = await response.json();
    
    return Object.keys(session).length > 0 ? session : null;
}

export default async function Presentation({params} : {params : {slug: string}}) {

    const presentation = await Presentations.findOne({presentationID: params.slug}).populate("user")
    
    const uploadDate = presentation ? new Date(presentation.createdAt) : undefined
    const date = uploadDate?.toLocaleDateString('de-DE', {year: 'numeric', month: '2-digit', day:'2-digit'});

    const session = await getSession(headers().get('cookie') ?? '')
    
    const userdata = session ? await getUserData(session.user?.email) : null

    if(!presentation || (presentation && presentation.visibility === "private")) return <NotFound />
    
    
    

    return (<PresentationPage images={presentation.images} tags={presentation.tags} avatar={presentation.user.profilePictureURL} description={presentation.description} displayname={presentation.user.displayname} file={presentation.file} grade={presentation.grade} title={presentation.title} username={presentation.user.username} date={date} lang={presentation.language} ownerid={presentation.user._id} currentUserId={userdata?.account?._id} presentationID={presentation.presentationID}/> )
};