Skip to content

Proof that sourceValue has a race condition#679

Draft
chuckdries wants to merge 12 commits intomainfrom
chuckdries/race-condition-testing
Draft

Proof that sourceValue has a race condition#679
chuckdries wants to merge 12 commits intomainfrom
chuckdries/race-condition-testing

Conversation

@chuckdries
Copy link
Copy Markdown
Contributor

@chuckdries chuckdries commented Aug 21, 2025

Onyx sourceValue issues

These tests demonstrate multiple issues with Onyx sourceValue handling:

  1. Race Condition: Multiple discrete updates batched → only last sourceValue visible to component
  2. Stale keys: sourceValue preserves the keys of the latest onyx update during unrelated rerenders

See the thread in #quality for more info

Test Files

simpleSourceValueRaceConditionDemo.ts - Race condition test proving batching loses intermediate sourceValues
useSidebarOrderedReportsVulnerability.ts - Logic bug and compound issue tests replicating production patterns Deleted, since useSidebarOrderedReports was refactored away from that pattern
staleSourceValueTest - Test demonstrating that sourceValue persists during unrelated renders, leading to unnecessary cache busting

How to Run the Tests

# Run the race condition test
npm test -- tests/unit/simpleSourceValueRaceConditionDemo.ts

# Run the useSidebarOrderedReports display bug tests
npm test -- tests/unit/useSidebarOrderedReportsDisplayBug.ts

# Run the staleSourceValueTest tests
npm test -- tests/unit/staleSourceValueTest.ts

# Or run all 3 at once
npm test -- tests/unit/simpleSourceValueRaceConditionDemo.ts tests/unit/useSidebarOrderedReportsDisplayBug.ts tests/unit/staleSourceValueTest.ts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 21, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@chuckdries
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

CLABotify added a commit to Expensify/CLA that referenced this pull request Aug 21, 2025
@chuckdries chuckdries force-pushed the chuckdries/race-condition-testing branch from 2bd9765 to 9c293d4 Compare April 20, 2026 17:30
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