fix(arcade): add automatic retry for version conflict rejections

When a move is rejected due to a version conflict (optimistic locking),
automatically retry the move after a brief delay. This handles the case
where moves arrive faster than the database can commit them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-10-23 13:18:55 -05:00
parent 71fd66d96a
commit fbcde2505f

View File

@@ -115,7 +115,14 @@ export function useArcadeSession<TState>(
},
onMoveRejected: (data) => {
console.log(`[ArcadeSession] Move rejected: ${data.error}`)
// For version conflicts, automatically retry the move
if (data.versionConflict) {
// Wait a tiny bit for server state to propagate, then retry
setTimeout(() => {
socketSendMove(userId, data.move, roomId)
}, 10)
}
optimistic.handleMoveRejected(data.error, data.move)
},