Skip to content

onBeforePrerenderStart called twice, leading to duplicate url error #2286

@sebastianeggers

Description

@sebastianeggers

Description

I am experimenting with vike and ssr, and have come upon an error.

My goal was to create a page with index and id, and have it pre-rendered.

These are my first steps with vike, so it is easily possible that I am overlooking something obvious.

What I have done:

  • Created a new vike project using npm create vike@latest --- --react --eslint
  • Removed the pages for todo and star-wars
  • Created new page called pokemon with @id and index
  • Made sure that the page works in dev mode
  • Added prerender: true to pages/+config.ts
  • Added a +onBeforePrerenderStart.ts file inside the folder of my page, it reads an api, and returns an array of url strings
  • Run npm run build

What I expect:

  • The pages are pre-rendered.

What I see:

  • I receive the error URL /pokemon/bulbasaur provided twice by the onBeforePrerenderStart() hook (/pages/pokemon/+onBeforePrerenderStart.ts). Make sure to provide the URL only once instead.
  • By adding logs, I see that the onBeforePrerenderStart hook is executed twice, in parallel (function starts, function starts, function ends, function ends). I have made sure that the returned url array does not contain duplicates.
  • Added .server or .shared makes no difference.
  • Adding .client leads to the page not being pre-rendered

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions