vercel/speed-insights

SpeedInsights import causes breaking changes on pages router

ingridkindem opened this issue · 3 comments

Nextjs with pages router.

Versions to reproduce:

    "@vercel/speed-insights": "^1.0.11",
    "next": "14.2.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",

When I add the <SpeedInsights /> to _app.tsx, the app breaks. When trying to build the project, I get Generating static pages (0/2) [ ]TypeError: Cannot read properties of null (reading 'entries').

Related issues:

I have tried to work around this with different versions, but not being able to find anything that works. Have deleted my .next folder and rebuilt the project for each install.

Any suggestions for compatible package versions that would make the build pass?

Hello @ingridkindem .
I couldn't reproduce the issue with a plain Next.js pages application pinned to the version you shared.
However there's only one place where it could fail, so I crafted a fix in @vercel/speed-insights@1.0.12.

Would you mind trying it please?

If it does not fix it, I'll need a reproduction code sandbox like this one.

@feugy Thanks for the quick reply and fix! It fixed the build issue, but unfortunately, I ran into the same issue described here now: #35

@ingridkindem, could you please create a code sandbox for it? I've never managed to reproduce it.