Skip to content

Fix useEffectEvent render-phase violation from synchronous emit()#11

Merged
ConsoleTVs merged 1 commit into
mainfrom
fix/useeffectevent-render-emission
May 10, 2026
Merged

Fix useEffectEvent render-phase violation from synchronous emit()#11
ConsoleTVs merged 1 commit into
mainfrom
fix/useeffectevent-render-emission

Conversation

@ConsoleTVs
Copy link
Copy Markdown
Member

Summary

  • Deferred two synchronous emit() calls for the refetching event using queueMicrotask()
  • subscribe() emitted synchronously when a pending resolver existed, triggering React's useEffectEvent render-phase guard
  • query() emitted synchronously after adding the resolver to cache, causing the same violation
  • Both now defer to microtask, running after React's render phase completes

Notes

All 61 existing tests pass. No behavioral change — events still fire in the same microtask tick, just not synchronously during the calling render frame.

…lations

Both emit() calls for the 'refetching' event fired synchronously during
React's render phase, triggering useEffectEvent errors. Wrapping in
queueMicrotask() defers them to after render completes.
@ConsoleTVs ConsoleTVs marked this pull request as ready for review May 10, 2026 22:08
@ConsoleTVs ConsoleTVs merged commit ffa22f6 into main May 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant