fix: NaN displayed in Sync New Content notification #125

Closed
opened 2026-03-24 09:48:06 -07:00 by hikari · 0 comments
Owner

Bug Report

Description

The "Sync New Content" notification displays NaN item(s) instead of the actual count of synced items.

Example output: Synced NaN item(s): 1 adventurer tier(s), 5 upgrade(s).

Root Cause

In apps/web/src/components/game/debugPanel.tsx, the buildSyncNewContentMessage function calculates a total via reduce over the count entries. If any count property from SyncNewContentResult is undefined (e.g. a newly added field not yet present in the player's saved state), the arithmetic produces NaN, which then gets interpolated directly into the message string.

Steps to Reproduce

  1. Sync new content when the game has been updated with new adventurer tiers or upgrades
  2. Observe the notification — the total count reads NaN

Expected Behaviour

The total should reflect the correct sum of all synced items (e.g. Synced 6 item(s): 1 adventurer tier(s), 5 upgrade(s).).

Suggested Fix

Guard against undefined/NaN values when building the entries array, or use nullish coalescing (?? 0) on each count property before passing it into the reduce.


This issue was created with help from Hikari~ 🌸

## Bug Report ### Description The "Sync New Content" notification displays `NaN item(s)` instead of the actual count of synced items. **Example output:** `Synced NaN item(s): 1 adventurer tier(s), 5 upgrade(s).` ### Root Cause In `apps/web/src/components/game/debugPanel.tsx`, the `buildSyncNewContentMessage` function calculates a `total` via `reduce` over the count entries. If any count property from `SyncNewContentResult` is `undefined` (e.g. a newly added field not yet present in the player's saved state), the arithmetic produces `NaN`, which then gets interpolated directly into the message string. ### Steps to Reproduce 1. Sync new content when the game has been updated with new adventurer tiers or upgrades 2. Observe the notification — the total count reads `NaN` ### Expected Behaviour The total should reflect the correct sum of all synced items (e.g. `Synced 6 item(s): 1 adventurer tier(s), 5 upgrade(s).`). ### Suggested Fix Guard against `undefined`/`NaN` values when building the entries array, or use nullish coalescing (`?? 0`) on each count property before passing it into the reduce. --- ✨ This issue was created with help from Hikari~ 🌸
naomi closed this issue 2026-03-24 13:20:37 -07:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nhcarrigan/elysium#125