next.js: Minified React Errors in production
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64
Binaries:
Node: 18.16.0
npm: 9.5.1
Yarn: N/A
pnpm: 8.5.1
Relevant packages:
next: 13.4.3
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/gaurishhs/Portfolio
To Reproduce
git clone https://github.com/gaurishhs/Portfolio.git
pnpm i
vc
Describe the Bug
I’m using next-themes
along with app directory and i get these Minified react errors in the production deployment only on Vercel. These errors are not there during development mode or if i use vc deploy
Expected Behavior
No such errors
Which browser are you using? (if relevant)
Brave Browser
How are you deploying your application? (if relevant)
Vercel
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 20
- Comments: 63 (12 by maintainers)
Quite disappointing to see that this is a growing issue and this has been open for 2 weeks yet no official response.
please guys this is such a bullshit error it can happen anytime anywhere basically, in complex web apps. we follow best practices of our stack but its sucks on both UX/DX sides. error is basically we are doing some calculations on server and we are doing same on client on hydrating, if results dont adds up, we throw error. it doesn’t make any sense, we don’t have to consider hydration of every server rendered value. we dont use simple
fetch()
and prop passing on our tutorial todo app. we heavily depend other global state and data fetching libraries. we cant trust client devices. for example if we have to use basic client releated feature for example Intl APIs/Web Senser APIs/global state persistence/optimistic data fetching etc… we have to hydrate as null and show suspense, and initialize it as second render. this is not well documented or tooled workflow as its sucks on user side we dont consider this. main thread completely blocking for a while if hydration occurs. we cant wrap everything is suspense or we cant make sure of every 3rd party lib./framework/client compatiable for us. this is painful job, sometimes I miss my getserversideprops days. this is not an issue back then. these new rsc approach is good but I think tooling and community around it sucks. sometimes I feel like I have to invest on another frontend framework/library.As i specified this does not occur at all on my machine whether i run it in dev or build and serve it. It happens only when i deploy on vercel. Seems like it’s something with Vercel
On Thu, 8 Jun, 2023, 21:50 Joseph, @.***> wrote:
I just installed a new, 100% untouched version of next.js, and this error is present.
The steps I followed: Step 1) I ran
npx create-next-app@latest
and thenStep 2) change the
next.config.js
as follows:Step 3) ran the next build command.
Step 4) cd to
/dist
and then I served the files with a local static site server (I usedbrowsersync
).The Errors I see:
Uncaught Error: Minified React error #418
Uncaught Error: Minified React error #423
There has been an ongoing discussion around this issue since Dec 2022; not sure why a ticket was not created: https://github.com/vercel/next.js/discussions/43921
This issue might be a
react 18
issue as GatsbyJs users report a similar issue: https://github.com/gatsbyjs/gatsby/discussions/36232Update: To rule out the possibility that a browser plugin was causing this issue, I viewed the next site in Google Chrome incognito and Safari incognito (I have no extensions enabled in incognito). Across both browsers, the exact same errors are still present.
I’m facing the same issue, I’ve downgraded my next version from
14.2.0
to14.1.4
and the error went away. Seems like the short term solution to this is to downgradeThis error started for us when updating to nextjs 14.2.0 only on production builds (Minified React error 306). We didn’t have that error on 14.1.4.
The same may happen if you are using i18next and react-i18next libraries and a backend to load the translations. Remember to surround with
<Suspense>
I have the same problem currently. In my case, I get 4 errors
next.config.js
I run
next build
then I publish it in s3 bucket behind cloudfront.Ok so this comes down to React 18 not being able to handle hydration errors very gracefully.
The solution seems to be to make a
entry.client.tsx
with the following which will use the React 17 hydrate function instead of the React 18 hydrateRoot function.We had the same issue with
14.2.2
, downgrading to14.1.4
does resolve the issue for us. I’ll try to provide a reproduction example tomorrow.For folks that were running into the
Minified React Error #306
after upgrading to14.2.0
or14.2.1
- this PR (that was included in14.2.2
) seemed to resolve the issue for us: https://github.com/vercel/next.js/pull/64558!In our case, we had the following in one of our
layout.tsx
files:I got the same error due to the time zone difference between the server and client.
I haven’t seen this one reported in the thread, so in case someone else encounters it, this error appeared because I used the
placeholder
attribute on aninput
. This is reproducible, so I created a public repo here, deployed it with Vercel to this site: https://input-with-placeholder.vercel.app/Please let me know if I should create a separate issue, and I’ll be happy to do so.
@DzTheRage japp date and locales can cause this issue easily. For example a call to
toLocaleUppercase
can break all hell loose…For these though, the supressHydrationWarning flag should suffice, https://react.dev/reference/react-dom/hydrate#suppressing-unavoidable-hydration-mismatch-errors
Our issue seems to be resolved after removing new Date() from inside render and putting that logic into a useEffect.
replace nextjs version 14.1.4 A self-test is available to solve this problem
Hi, I want to pitch in, that we also experience this when upgrading to
14.2.1
(Minified React error 306). This can only be observed in the production build, the development build ran fine. And I was very hyped about the DX improvements to error messages. Downgrading to14.1.4
fixed the issue for us.I’m sorry I can’t provide something more useful as to why this may be happening.Edit: we narrowed it down to a component that also re-exports types from another file with types. Removing this re-export fixed it!
Thanks I’ll try this out @adriancmiranda 🙏
We had same issues with many 418 and 422 minified errors and in the end I tracked them to some components loaded dynamically with next/dynamic and ssr=false. The errors were not reproducible all the time. We only could see them randomly and in our exception logs in Application Insights. I used the approach from @adriancmiranda to replace that ssr=false with a shell component that would render the content client side only. It is working with dynamic components also
this should work 4
Uncaught Error: Minified React error #423
Same error for my case images were affected , images are not showing , don’t know what to do AWS Amplify, Cloudfront auto configuration I am sorry but , I shouldn’t choose this framework for production it’s absolutely pain in head. every now and then error and error I am tired of this framework and issues I am using nextjs version = 13.5.4
This tip maybe help. Make sure your pre-render data doesn’t change in the client side. If you want to change it, change it in useEffect
just wrap
<Suspense>
on root layout’s children makes it works, in my case.@wub Getting this on a Remix + React 18 + Vercel deployment too.
Completely fresh project with only a root.tsx and index.tsx file with Chakra UI installed
https://thingtime.com
Edit:
I’ve tracked this down to the Vimeo Screen Recorder Chrome Extension. Although I was getting this error on my friend’s iPhone too which wouldn’t have had this extension.
Disabling the extension fixes the issue on my Laptop.
This even happens on the official Vercel Remix Starter deployment
https://remix-run-template.vercel.app/
We’re getting the same issues with Remix, and only on Vercel. Hard to pin down!
131k of these errors in Bugsnag since April 16th.
Potential causes I’ve read while debugging this.