Skip to content

fix: prevent crash when entry.cost becomes undefined between Show condition and render - #13

Merged
Hotakus merged 3 commits into
Hotakus:masterfrom
kilng235:fix/cost-tofixed-crash
Jul 27, 2026
Merged

fix: prevent crash when entry.cost becomes undefined between Show condition and render#13
Hotakus merged 3 commits into
Hotakus:masterfrom
kilng235:fix/cost-tofixed-crash

Conversation

@kilng235

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a crash where entry.cost.toFixed(4) throws "undefined is not an object" when entry.cost becomes undefined between the Show condition check and the child render
  • Wraps the Show children in an IIFE to capture entry.cost in a local variable, closing the reactive race window

Problem

SolidJS Show component's when condition and child render can be separated by a reactive tick. If entry.cost transitions from a number to undefined between the guard check and the child function executing, entry.cost!.toFixed(4) throws because entry.cost is now undefined.

Solution

Capture entry.cost in a local const inside an IIFE within the Show children. This ensures the value is snapshotted at render time, preventing the race condition.

Test plan

  • Verify that the SubAgentPanel no longer crashes when entry.cost changes from a number to undefined during reactive updates
  • Verify that cost display still works correctly when entry.cost has a valid value

🤖 Generated with Claude Code

kilng235 added 3 commits July 28, 2026 00:03
…dition and render

SolidJS Show's `when` condition and child render can be separated by a
reactive tick. If entry.cost transitions from a number to undefined
between the guard check and the child function executing, `entry.cost!.toFixed(4)`
throws "undefined is not an object". Capturing the value in an IIFE closes
the race window.
…dition and render

SolidJS Show's `when` condition and child render can be separated by a
reactive tick. If entry.cost transitions from a number to undefined
between the guard check and the child function executing, `entry.cost!.toFixed(4)`
throws \"undefined is not an object\". Capturing the value in an IIFE closes
the race window.
…dition and render

SolidJS Show's `when` condition and child render can be separated by a reactive tick. If entry.cost transitions from a number to undefined between the guard check and the child function executing, `entry.cost!.toFixed(4)` throws "undefined is not an object". Capturing the value in an IIFE closes the race window.
@Hotakus Hotakus self-assigned this Jul 27, 2026
@Hotakus Hotakus added the bug Something isn't working label Jul 27, 2026
@Hotakus

Hotakus commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix. I'll merge the PR and push an update soon. Appreciate your support.

@Hotakus
Hotakus merged commit 92400d6 into Hotakus:master Jul 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants