facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
225.93k stars 46.09k forks source link

[Compiler Bug]: healthcheck do not check next.js StrictMode #30049

Open coleea opened 1 month ago

coleea commented 1 month ago

What kind of issue is this?

Link to repro

https://github.com/coleea/bug-report-next15-server-action

Repro steps

just run command npx react-compiler-healthcheck@latest. then, react-compiler-healthcheck does not check StrictMode even though Next.js is actually StrictMode.

Next.js is StrictMode by default under these two conditions are met

1) Next.js version 13.4+ 2) App router

You can check this : https://rc.nextjs.org/docs/app/api-reference/next-config-js/reactStrictMode

So, It needs extra three steps to check whether StrictMode or Not. 1) check package.json if Next.js version is over 13.4 or not. 2) If so, Check if reactStrictMode: false is not set. 3) check if project is App-Router-based.

If three conditions are met, this project is based on StrictMode even though reactStrictMode: true is not set on next.config.mjs file.

How often does this bug happen?

Every time

What version of React are you using?

19.0.0-rc.0

coleea commented 1 month ago

If my argument is not wrong, I am willing to implement it, so please reply

gsathya commented 1 month ago

This is already fixed: https://github.com/facebook/react/pull/29167

This will roll out once we make a new release of the healthcheck script

coleea commented 1 month ago

@gsathya The PR you mentioned is just check whether reactStrictMode: true option exists in next.config.mjs or not. that's not enough. I wrote this issue after reading this PR.

coleea commented 1 month ago

There are 6 cases

1) App router + reactStrictMode: true => strict mode. PR cover this case. 2) App router + reactStrictMode: false => non-strict mode. PR cover this case. 3) App router + reactStrictMode option is not set => strict mode. PR does not cover this case. 4) Page router + reactStrictMode: true => strict mode. PR cover this case. 5) Page router + reactStrictMode: false => non-strict mode. PR cover this case. 6) Page router + reactStrictMode option is not set => non-strict mode. PR cover this case.

Please check the 3rd case to determine whether #29167 covers this or not.

gsathya commented 1 month ago

Ah good point, I'll re-open this.