Debug "Enter Spire Mode" crashes with React error #185 (infinite render loop) #252

Closed
opened 2026-06-01 15:06:21 +02:00 by Anexim · 1 comment
Owner

Steps to reproduce:

  1. Open Debug tab → Spire section
  2. Click "Enter Spire Mode"

Expected: Spire combat UI appears with floor 1

Actual: Full-screen crash with React error #185 "Maximum update depth exceeded". Game requires error boundary recovery.

Root cause: The SpireCombatPage component has a potential infinite re-render loop. When spireMode changes to true, the component renders and creates seededRandom via useMemo(() => ..., [currentFloor]). This function is then used in totalRooms useMemo which depends on [currentFloor, seededRandom]. The useEffect([currentFloor, totalRooms, setCurrentRoom]) then calls setCurrentRoom(newRoom) which triggers a store update. If getFloorMaxHP(1) or generateSpireFloorState(1, 0, totalRooms) returns a new object reference each time, this could trigger another render cycle before React can bail out.

Affected files:

  • src/components/game/tabs/SpireCombatPage/SpireCombatPage.tsx — the seededRandom, totalRooms, and useEffect hooks
  • src/lib/game/stores/gameLoopActions.tsenterSpireMode action

Store: useCombatStore (spireMode, currentFloor, currentRoom, etc.)

**Steps to reproduce:** 1. Open Debug tab → Spire section 2. Click "Enter Spire Mode" **Expected:** Spire combat UI appears with floor 1 **Actual:** Full-screen crash with React error #185 "Maximum update depth exceeded". Game requires error boundary recovery. **Root cause:** The `SpireCombatPage` component has a potential infinite re-render loop. When `spireMode` changes to `true`, the component renders and creates `seededRandom` via `useMemo(() => ..., [currentFloor])`. This function is then used in `totalRooms` useMemo which depends on `[currentFloor, seededRandom]`. The `useEffect([currentFloor, totalRooms, setCurrentRoom])` then calls `setCurrentRoom(newRoom)` which triggers a store update. If `getFloorMaxHP(1)` or `generateSpireFloorState(1, 0, totalRooms)` returns a new object reference each time, this could trigger another render cycle before React can bail out. **Affected files:** - `src/components/game/tabs/SpireCombatPage/SpireCombatPage.tsx` — the `seededRandom`, `totalRooms`, and `useEffect` hooks - `src/lib/game/stores/gameLoopActions.ts` — `enterSpireMode` action **Store:** `useCombatStore` (spireMode, currentFloor, currentRoom, etc.)
Anexim added the ai:todo label 2026-06-01 15:06:21 +02:00
n8n-gitea was assigned by Anexim 2026-06-01 15:06:21 +02:00
Author
Owner

Duplicate of issue #250 — same root cause (React #185 infinite render loop in SpireCombatPage). Fix will be tracked under #250.

Duplicate of issue #250 — same root cause (React #185 infinite render loop in SpireCombatPage). Fix will be tracked under #250.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#252