Skip to content

Race Condition in Freebet Selection When Switching Chains #245

@utgarda

Description

@utgarda

Problem

When selecting a freebet that requires a chain switch, there's a race condition where the freebet and token are set immediately while the chain switch is still pending. This causes a brief inconsistent state where:

  • The selected freebet is from Chain B
  • The app is still on Chain A
  • The token displayed may be incorrect

Steps to Reproduce

  1. Connect wallet on Chain A (e.g., Polygon)
  2. Have freebets available on both Chain A and Chain B (e.g., Base)
  3. Select a freebet from Chain B
  4. Observe that the freebet/token are set before the chain actually switches

Expected Behavior

  • Chain should switch first
  • Only after successful chain switch should the freebet and token be selected
  • No intermediate inconsistent state should be visible

Current Behavior

  • Freebet and token are set immediately
  • Chain switch happens asynchronously afterward
  • Brief period where selected freebet doesn't match current chain

Impact

  • Confusing UX during chain switches
  • Potential for incorrect token display
  • May cause issues with bet placement if user acts during the inconsistent state

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions