"Climb the Spire causes React crash (Minified React error #185)" #229
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description: Clicking "Climb the Spire" crashes the game with Minified React error #185 ("Maximum update depth exceeded").
Root Cause Investigation:
The
enterSpireModeaction incombatStore.tssetscurrentAction: 'climb'andspireMode: true. This triggerspage.tsxto render<SpireCombatPage />inside an<ErrorBoundary>.The
SpireCombatPagecomponent usesuseSpireStats()which callscomputeDisciplineEffects(). This function accessesuseDisciplineStore.getState()and iterates all disciplines. If discipline state is somehow corrupted or triggers re-renders during render (e.g., re-computing discipline effects triggers state updates), it can cause an infinite render loop.Additionally, the
useMemocalls inside the component depend onequippedInstancesandequipmentInstancesfromuseCraftingStore, which are accessed outside ofuseShallow(as bare selectors), potentially causing unnecessary re-renders.Files involved:
src/app/page.tsx— conditional render of SpireCombatPagesrc/components/game/tabs/SpireCombatPage/SpireCombatPage.tsx— the spire combat pagesrc/lib/game/stores/combatStore.ts—enterSpireModeactionLikely triggers:
computeDisciplineEffects()called during render may cause cascading state readsgenerateSpireFloorStateusesMath.random()during render insideuseMemo, causing referential instabilitytotalRoomsanduseEffectcallingsetCurrentRoomcan trigger render loops whencurrentFlooris a guardian floor (getRoomsForFloor returns 1, but the effect re-runs)Repro: Start a game, click "Climb the Spire" button. React error #185 appears immediately.
AGENTS.md rules: All fixes must keep files under 400 lines.
Starting work on the Spire crash fix (React error #185 - Maximum update depth exceeded). Investigating the root cause in SpireCombatPage.tsx, page.tsx, and combatStore.ts.
Fixed React crash #185 (infinite render loop) when entering Spire mode. Two root causes addressed:\n1. getRoomsForFloor() used Math.random() making totalRooms unstable — replaced with deterministic seeded random in component\n2. useCraftingStore selectors for equippedInstances/equipmentInstances lacked useShallow — wrapped in useShallow to prevent unnecessary re-renders\n\nAll 36 spire-utils tests pass.