Skip to content

[Compiler Bug]: for await loop fails to optimize component. #33075

Open
@suneettipirneni

Description

@suneettipirneni

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhHCA7MAXABAQwCMcZ85sEATXAXgLAE8M5cAKASloD5dgAdDLiG4AZhBgEA7vgCWeVuix4xEXBBG5C+GJ36DhQgQYC+R3KYwCEADwAO4vJQQj8UADbKozbDMy4AsgwAgra2HLwCZoo4uJQQAMoQALYI2AAWMhgA5rT0TCzhNDx6BmIS+NJybNHKEKrqmtq6kfpCFm0tQjCpsIIAPJQyAG5cABIIbm6qAOribpR9APSDIwDcAhYgxkA

Repro steps

React compiler fails to optimize components that contain for await loops. I came across this bug while trying to deduce the cause of a significant amount of re-renders. In the react dev tools it showed the component was indeed auto-memoized, however it would still re-rerender when seeing the same props. When removing for await from my code the component properly memoized inputs.

Later I tested this in the react compiler playground and noticed the very clear Todo: (BuildHIR::lowerStatement) Handle for-await loops (10:12) error message. Ideally this error could be addressed or surfaced to the user in order to prevent confusion on why a component marked as auto-memoized isn't actually being memoized.

How often does this bug happen?

Every time

What version of React are you using?

19.1

What version of React Compiler are you using?

rc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions