Skip to content

Incorrect production enviroment detection #402

Closed

Description

@ha1fstack

React Scan would not run in many conditions where multiple react root exists, such as Next.js dev environment.

export const getIsProduction = () => {

export const getIsProduction = () => {
  if (isProduction !== null) {
    return isProduction;
  }
  rdtHook ??= getRDTHook();
  for (const renderer of rdtHook.renderers.values()) {
    const buildType = detectReactBuildType(renderer);
    if (buildType === 'production') {
      isProduction = true;
    }
  }
  return isProduction;
};
Image Image

For example, in Next.js dev environment, the next-devtools overlay uses production build of react and has separate root.

getIsProduction helper wrongly sets isProduction to true, so react-scan is not enabled.

For temporary workaround, you can set dangerouslyForceRunInProduction option to true and use other methods to decide whether to run scan.

Activity

  1. RobPruzan commented on Aug 5, 2025

    @RobPruzan
    Contributor

    Thanks for the issue, will get this fixed!

  2. brunocapdevila commented on Sep 10, 2025

    @brunocapdevila

    Same issue

  3. zhsama commented on Dec 3, 2025

    @zhsama

    you may use a trick be like

        if (IS_DEV) {
          scan({
            enabled: true,
            dangerouslyForceRunInProduction: true,
          })
        }
  4. aidenybai commented on May 2, 2026

    @aidenybai
    Owner

    Fixed in v0.5.5 via #437.

    getIsProduction() was caching true as soon as any single registered renderer reported a production build, which made the Next.js dev overlay's production React renderer disable React Scan entirely. The fix:

    • Cache false permanently once a non-production renderer is observed.
    • Never cache true — a later dev renderer can still flip the result.

    Added a regression test matrix that mocks bippy's getRDTHook / detectReactBuildType for: empty renderers, all production, mixed, production-then-dev (regression guard), and dev-then-anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions