Skip to content

Incorrect production enviroment detection #402

@ha1fstack

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions