Skip to content

Bug: #35221

@kl2400033266

Description

@kl2400033266

Description

I observed that the cleanup function inside useEffect does not always trigger when
there are rapid, consecutive state updates. This leads to stale subscriptions and
unexpected behavior in components that rely on cleanup.

Steps to Reproduce

  1. Create a component with a useEffect that logs cleanup.
  2. Trigger state updates inside a loop or with very small intervals (5–10ms).
  3. Observe that cleanup logs are skipped or delayed.

Expected Behavior

Cleanup should run reliably before every re-invocation of the effect, regardless of
how fast state is updated.

Actual Behavior

Cleanup is inconsistently triggered during extremely fast re-renders.

Version

  • React: Latest main branch
  • Environment: Browser (Chrome/Edge)
  • OS: Windows 10 / macOS (tested both)

Additional Info

Issue seems more noticeable in strict mode, possibly due to double rendering behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions