[GH-ISSUE #1757] Gacha Forge: a stale /battle reply can replace a fight entered again while it loads #1735

Closed
opened 2026-11-07 16:36:19 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @SpicyMarinara on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1757

Originally assigned to: @SpicyMarinara on GitHub.

Found during review of #1754. This race predates that PR; it dates from 1.1.0.

Scenario. Enter a battle, back out while its /battle (or /farm/battle, /tower/battle) request is still loading, then enter a different fight.

  • _loadBattle returns early because _battleLoading is still set, so the new fight sends no request.
  • When the old reply lands, it sets _combatNode = {...oldNode} and _combatPhase = "prebattle".
  • The player sees, and can start, the fight they left.

Suggested fix. Keep a load token: _battleLoadSeq.

  • _enterBattle and _leaveCombat bump it and clear _battleLoading.
  • The reply handler drops any payload whose token is no longer current, and doesn't touch _combat* state.
  • _farmBusy is released only when no newer load is running.

Low priority: it needs a slow battle request plus a quick back-and-re-enter.

Originally created by @SpicyMarinara on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1757 Originally assigned to: @SpicyMarinara on GitHub. Found during review of #1754. This race predates that PR; it dates from 1.1.0. **Scenario.** Enter a battle, back out while its `/battle` (or `/farm/battle`, `/tower/battle`) request is still loading, then enter a different fight. - `_loadBattle` returns early because `_battleLoading` is still set, so the new fight sends no request. - When the old reply lands, it sets `_combatNode = {...oldNode}` and `_combatPhase = "prebattle"`. - The player sees, and can start, the fight they left. **Suggested fix.** Keep a load token: `_battleLoadSeq`. - `_enterBattle` and `_leaveCombat` bump it and clear `_battleLoading`. - The reply handler drops any payload whose token is no longer current, and doesn't touch `_combat*` state. - `_farmBusy` is released only when no newer load is running. Low priority: it needs a slow battle request plus a quick back-and-re-enter.
bsakaguchi 2026-11-07 16:36:19 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@SpicyMarinara commented on GitHub (Oct 27, 2026):

Claude Code (for SpicyMarinara) is working on this in branch fix/gacha-forge-1745-1757-1761, together with #1745, #1757 and #1761, as Gacha Forge 1.25.2. A draft PR will follow.

<!-- gh-comment-id:6453553422 --> @SpicyMarinara commented on GitHub (Oct 27, 2026): Claude Code (for SpicyMarinara) is working on this in branch `fix/gacha-forge-1745-1757-1761`, together with #1745, #1757 and #1761, as Gacha Forge 1.25.2. A draft PR will follow.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#1735
No description provided.