TypeError
Cannot read properties of undefined (reading 'total')
Crash-nearest frame first. Frames in your code open with their source.
applyCoupon src/checkout/coupon.ts:42in app
38export function applyCoupon(cart: Cart, code?: string) { 39 if (!code) return cart.total 40 const rules = loadRules() 41 const rule = rules.get(code) 42 return cart.total - cart.total * rule.total 43}priceCart src/checkout/cart.ts:118in app
117 const subtotal = sum(lines) 118 const total = applyCoupon({ ...cart, total: subtotal }, cart.coupon) 119 return { lines, total }
POST /api/checkout src/routes/checkout.ts:27in app
26 const cart = await loadCart(req.session.cartId) 27 const priced = priceCart(cart) 28 res.json(await createOrder(priced))
handle node_modules/express/lib/router/layer.js:95library
next node_modules/express/lib/router/route.js:149library
processTicksAndRejections node:internal/process/task_queues:95library
The last 20 breadcrumbs before the event, oldest first.
- 08:58:40.517httpGET /api/cart 200
- 08:58:41.102httpPOST /api/checkout
- 08:58:41.164querySELECT id, lines, coupon FROM carts WHERE id = $1
- 08:58:41.211httpGET http://rules.internal/coupons 200
- 08:58:41.280consolepricing cart c_8f21, 3 lines
- 08:58:41.287consolecoupon WINTER25 is not in the rules table
Logs of trace 7a3e91c04d5b within an hour, up to 50. Without a trace, 30 lines of the project from 60 s before the event to 10 s after.
- 08:58:40.517infoGET /api/cart 200 in 18 ms
- 08:58:41.102infoPOST /api/checkout started
- 08:58:41.170debugcart c_8f21 loaded, 3 lines, coupon WINTER25
- 08:58:41.287warncoupon WINTER25 is not in the rules table
- 08:58:41.290errorTypeError: Cannot read properties of undefined (reading 'total')
- 08:58:41.296infoPOST /api/checkout 500 in 194 ms
The Pay button shows an error and nothing happens. Tried twice.
Unreleased Davy takes what users write in the Sentry feedback widget, on main and not in 0.1.0. Your agent reads the newest 10 with issue_context or davy context. The web UI does not show them yet.