Skip to content

Comments

fix: prevent race condition and memory leaks in MatchingPage#315

Open
ArtemZhyto wants to merge 1 commit intochicagopcdc:masterfrom
ArtemZhyto:fix/matching-page-race-condition
Open

fix: prevent race condition and memory leaks in MatchingPage#315
ArtemZhyto wants to merge 1 commit intochicagopcdc:masterfrom
ArtemZhyto:fix/matching-page-race-condition

Conversation

@ArtemZhyto
Copy link

@ArtemZhyto ArtemZhyto commented Feb 20, 2026

This PR addresses a high-severity race condition in MatchingPage.tsx where rapid user input changes could cause stale data to overwrite the latest results.

Changes:

  1. Race Condition Fix: Implemented a cleanup flag pattern (isCancelled) within useEffect. This ensures that only the response from the most recent request is applied to the state.
  2. Request Coordination: Used Promise.all to synchronize getMatchDetails and getMatchGroups updates, preventing UI flickering.
  3. Memory Leak Prevention: The cleanup function now correctly prevents React state updates if the component unmounts while requests are still pending.
  4. Root Cause Analysis: Previously, parallel async requests could return out of order. If an older request resolved after a newer one, the UI would display outdated information. This fix guarantees that data remains consistent with the user's current input.

Fixes #279

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.

[Bug] Race condition in MatchingPage - async requests can return out of order

1 participant