vercel / analytics

Privacy-friendly, real-time traffic insights
https://vercel.com/analytics
Mozilla Public License 2.0
422 stars 26 forks source link

TypeError: Cannot read properties of null (reading 'useEffect') [Next.JS v13.4.0] #79

Closed jd-carroll closed 1 year ago

jd-carroll commented 1 year ago

Problem

Adding <Analytics /> causes the build to break on vercel.com

I am trying to understand this, but running the build locally (next build) works great. When I push my changes up into GitHub / Vercel, the build breaks. For every page listed under the /pages directory I get the error:

Error occurred prerendering page "/my-page". Read more: https://nextjs.org/docs/messages/prerender-error
--
15:38:49.692 | TypeError: Cannot read properties of null (reading 'useEffect')
15:38:49.692 | at exports.useEffect (/vercel/path0/node_modules/react/cjs/react.production.min.js:24:292)
15:38:49.692 | at Analytics (file:///vercel/path0/node_modules/@vercel/analytics/src/react.tsx:33:3)
15:38:49.692 | at Ge (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:114:273)
15:38:49.692 | at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:91)
15:38:49.693 | at He (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:123:155)
15:38:49.693 | at Je (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:122:100)
15:38:49.693 | at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:222)
15:38:49.693 | at He (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:123:155)
15:38:49.693 | at Ge (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:115:215)
15:38:49.694 | at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:91)
15:38:49.696 | TypeError: Cannot read properties of null (reading 'useEffect')
15:38:49.696 | at exports.useEffect (/vercel/path0/node_modules/react/cjs/react.production.min.js:24:292)
15:38:49.697 | at Analytics (file:///vercel/path0/node_modules/@vercel/analytics/src/react.tsx:33:3)
15:38:49.697 | at Ge (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:114:273)
15:38:49.697 | at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:91)
15:38:49.697 | at He (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:123:155)
15:38:49.697 | at Je (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:122:100)
15:38:49.697 | at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:222)
15:38:49.697 | at He (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:123:155)
15:38:49.698 | at Ge (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:115:215)
15:38:49.698 | at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:91)

I have tried listing the <Analytics /> in both the _app.tsx and _document.tsx, but neither location seem to work.

Any ideas?

jd-carroll commented 1 year ago

It appears as though the issue is with Vercel-CLI, but given that I am on a hobby account, I cannot open an issue 💩

jd-carroll commented 1 year ago

For reference:

jd-carroll commented 1 year ago

Also, of all the issues I've seen, this one might be the most relevant:

https://github.com/vercel/next.js/issues/42588

jd-carroll commented 1 year ago

Actually, it may not be the CLI, apologies for all the noise around this I am trying to understand but definitely a little lost

Looks like there is an active discussion here: https://github.com/vercel/next.js/issues/49261

Closing.