TypeError: Cannot read properties of undefined (reading <str>)
Diagnosis
Checkout reads the cart total before the cart loads.
Root cause
getCart in src/cart.js returns undefined for an expired session, and handler in src/checkout.js reads cart.total without a check.
Evidence
LOGTypeError: Cannot read properties of undefined (reading 'total')
2026-10-29T14:52:14Z
CODEcart.total read without a check
Confidence: High
Files
- src/checkout.js
Suggested fix
Return 404 from handler when getCart returns undefined.
Return 404 when the session's cart is gone
Removed: const total = cart.total;Added: if (!cart) return new Response("Cart not found", { status: 404 });Added: const total = cart.total;