Redwood V3 - Can't pre render more than one file

Hi Folks.

Getting stuck into testing RWv3. I have an issue where I can’t pretender more than one URL and I’m getting errors like these:

TypeError: globalObject.document.addEventListener is not a function
    at new BrowserClient (/Users/shan/Documents/GitHub/safer-qr/node_modules/src/client.ts:76:1).......It goes on.

My route hooks file seems to be working fine. Eg:

import { db } from '$api/src/lib/db'

export async function routeParameters() {
  return(await db.url.findMany({
    where: {
      OR: [
      {playlist: {
        is: {}
      }},
      {video: {
        is:{}
      }}]
    },
    select: {slug: true}
  })
  ).map(({slug}) => ({id: slug}))
}

And to make troubleshooting a little easier I have stripped down my page component .eg:

import { MetaTags } from '@redwoodjs/web'

import { analytics } from 'src/App'
import UserVideoCell from 'src/components/UserVideoCell'
const VideoPage = ({ id }) => {
  // analytics.page('Viewed video page')
  return (
    <>
      {/* <MetaTags
        title={`${global.__REDWOOD__APP_TITLE} - ${id}`}
        description="Video page"
      /> */}
<p>The page {id}</p>
      {/* <UserVideoCell slug={id} /> */}
    </>
  )
}

export default VideoPage

The end result Is I get one successful pre-render and the rest fail with the error above. eg

Prerendering /v1/7PpoKYifxz8oH2aosBmjSu -> web/dist/v1/7PpoKYifxz8oH2aosBmjSu.html. <-----This worked
  ✖ Prerendering /v1/gCpyme6zAfaYJl5ckK5QZ4 -> web/dist/v1/gCpyme6zAfaYJl5ckK5QZ4.html
    → Failed to render "/Users/shan/Documents/GitHub/safer-qr/web/src/pages/VideoPage/VideoPage.js"
    Prerendering /v1/NcbvO1NU_zdfty56wX6ZIi -> web/dist/v1/NcbvO1NU_zdfty56wX6ZIi.html
    Prerendering /v1/TeTFgJTQALe2870HOyBITS -> web/dist/v1/TeTFgJTQALe2870HOyBITS.html
    Prerendering /v1/lUrJpGwjaoX8YJsF27L8pl -> web/dist/v1/lUrJpGwjaoX8YJsF27L8pl.html
    Prerendering /v1/GnEQ-aNlo-uD3f4JxZ8hhM -> web/dist/v1/GnEQ-aNlo-uD3f4JxZ8hhM.html

I’m not really sure where to go from here. Am I doing something wrong? Have I hit a bug? Help appreciated.

@shansmith01 thanks for taking debugging steps and reporting! Judging by the error it seems like code that expects to run in a browser is being called and failing because it’s in a node context. Have you tried removing the imports even? Maybe they have side effects and are executing code just by being imported. @danny @Tobbe thoughts on what could be going on here?

Yeah removing the imports got it working. Thanks.

As an aside, running “rw prernder” and rendering about 40-pages kill’s My M1 macs perf for about 3 minutes after. Not sure if anyone else is coming across this.