'Next.js SSR Portals error when portals is never imported
I have a Next.js app that is suffering an intermittent fatal error that requires Node to be restarted to make it go away.
The minified error refers to here: https://reactjs.org/docs/error-decoder.html/?invariant=257
But I never use Portals anywhere in my codebase. It's not even imported anywhere.
The fact that this is intermittent has me totally stumped. Any help would be greatly appreciated.
Mar 18 10:35:04 jsfitpapp npm[2783]: Error: Minified React error #257; visit
https://reactjs.org/docs/error-decoder.html?invariant=257 for the full message or use the non-minified
Mar 18 10:35:04 jsfitpapp npm[2783]: at a.b.render (/opt/fitbox/apps/app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:42:199)
Mar 18 10:35:04 jsfitpapp npm[2783]: at a.b.read (/opt/fitbox/apps/app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:83)
Mar 18 10:35:04 jsfitpapp npm[2783]: at Object.exports.renderToString (/opt/fitbox/apps/app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:52:138)
Mar 18 10:35:04 jsfitpapp npm[2783]: at Object.renderPage (/opt/fitbox/apps/app/node_modules/next/dist/server/render.js:751:45)
Mar 18 10:35:04 jsfitpapp npm[2783]: at Object.defaultGetInitialProps (/opt/fitbox/apps/app/node_modules/next/dist/server/render.js:389:51)
Mar 18 10:35:04 jsfitpapp npm[2783]: at Function.getInitialProps (/opt/fitbox/apps/app/.next/server/chunks/859.js:618:16)
Mar 18 10:35:04 jsfitpapp npm[2783]: at Object.loadGetInitialProps (/opt/fitbox/apps/app/node_modules/next/dist/shared/lib/utils.js:69:29)
Mar 18 10:35:04 jsfitpapp npm[2783]: at renderDocument (/opt/fitbox/apps/app/node_modules/next/dist/server/render.js:764:48)
Mar 18 10:35:04 jsfitpapp npm[2783]: at Object.renderToHTML (/opt/fitbox/apps/app/node_modules/next/dist/server/render.js:828:34)
Mar 18 10:35:04 jsfitpapp npm[2783]: at processTicksAndRejections (internal/process/task_queues.js:95:5)
Mar 18 10:35:04 jsfitpapp npm[2783]: at async doRender (/opt/fitbox/apps/app/node_modules/next/dist/server/base-server.js:879:38)
Mar 18 10:35:04 jsfitpapp npm[2783]: at async cacheEntry.responseCache.get.isManualRevalidate.isManualRevalidate (/opt/fitbox/apps/app/node_modules/next/dist/server/base-server.js
Mar 18 10:35:04 jsfitpapp npm[2783]: at async /opt/fitbox/apps/app/node_modules/next/dist/server/response-cache.js:64:36
Solution 1:[1]
If you aren't creating a Portal directly, I would debug by removing 3rd party components until the error disappears. Maybe it's some kind of component for creating modals or notifications? When you find it, add some conditional rendering to avoid rendering that component on the server.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Cameron Pittman |
