[critical] Sync pull completion silently overwrites wins that occurred during the fetch #11

Closed
opened 2026-05-19 18:42:00 +00:00 by funman300 · 0 comments
Owner

File

solitaire_engine/src/sync_plugin.rs lines 206, 224–227

Description

poll_pull_result builds the local snapshot (build_payload) at task-spawn time (line 206) and writes back the merged result at lines 225–227. The fetch task runs in the background for multiple frames. If the player wins a game between task-spawn and task-completion, update_stats_on_win and award_xp_on_win have already committed the win to the Stats, Achievements, and Progress resources. When poll_pull_result fires, it merges using the pre-win local snapshot and overwrites the current resources with the stale merged result — the win is silently discarded.

Fix

Call build_payload at poll time (using the current resource values) rather than at spawn time. The async task only needs the remote payload; the local half of the merge should be read from current resources when the result arrives.

## File `solitaire_engine/src/sync_plugin.rs` lines 206, 224–227 ## Description `poll_pull_result` builds the local snapshot (`build_payload`) at task-spawn time (line 206) and writes back the merged result at lines 225–227. The fetch task runs in the background for multiple frames. If the player wins a game between task-spawn and task-completion, `update_stats_on_win` and `award_xp_on_win` have already committed the win to the `Stats`, `Achievements`, and `Progress` resources. When `poll_pull_result` fires, it merges using the **pre-win** local snapshot and overwrites the current resources with the stale merged result — the win is silently discarded. ## Fix Call `build_payload` at poll time (using the current resource values) rather than at spawn time. The async task only needs the remote payload; the local half of the merge should be read from current resources when the result arrives.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#11