#DELETE /store/carts/:cartId/line-items/:itemId throws error when it is the last item in cart

11 messages · Page 1 of 1 (latest)

idle tapir
#

If you create payment session and then try to empty the cart you get an error:

 parameters: [ NaN, 'ps_01GY5Z7V44F2FQ4J0RGE6PERVJ' ],```

This is happening with 1.8.0 and Stripe Plugin 2.0. I had reported a similar issue which was fixed but this appears to be a new type of error. https://github.com/medusajs/medusa/issues/3333
latent lagoon
#

I can't reproduce this issue. Looking at the github issue you linked, you write about an error from the Stripe logs. You seem to be making a request to Stripe that throws the error. Can you give the clear sequence of what queries you are making to what endpoints, and where exactly you get the error? Might this have something to do with the way you have implemented stripe on the frontend? I added some things to cart, selected a payment session, and then deleted all items from the cart one by one. I did not get any errors in the medusa console or the stripe logs.

idle tapir
#
POST /store/carts/cart_01GY5DT2NZD25TSTGJ0QC97WY8/line-items
GET /store/shipping-options/cart_01GY5DT2NZD25TSTGJ0QC97WY8
POST /store/carts/cart_01GY5DT2NZD25TSTGJ0QC97WY8/shipping-methods
POST /store/carts/cart_01GY5DT2NZD25TSTGJ0QC97WY8
POST /store/carts/cart_01GY5DT2NZD25TSTGJ0QC97WY8/payment-sessions
POST /store/carts/cart_01GY5DT2NZD25TSTGJ0QC97WY8/payment-session
DELETE /store/carts/cart_01GY5DT2NZD25TSTGJ0QC97WY8/line-items/item_01GY84VC6YM91P92K9KMMQ9P7F```

Throws error on the last line.
latent lagoon
#

Throws an error where? In the medusa console? Please post the error

#

Is it in the postgres log?

idle tapir
idle tapir
latent lagoon
#

Have you been able to reproduce the error with the default medusa nextjs starter? I get a large number of request errors when I look at the network tab of the console log, even before I attempt to checkout.

idle tapir
#

Those 400s you see in the request log is some polling stuff.

I looked at this more and on this line total is evaluated to NaN which results in this error. https://github.com/medusajs/medusa/blob/649bb6aa999a50c91d603dc18ccd6559b1819eb2/packages/medusa/src/services/cart.ts#L1843

This makes sense as on this line when total is calculated, no checks are done on whether what's being added isn't a NaN https://github.com/medusajs/medusa/blob/649bb6aa999a50c91d603dc18ccd6559b1819eb2/packages/medusa/src/services/cart.ts#L2641

In my case the values are as following:

discount_total: 0,
item_tax_total: 0,
shipping_total: 0,
shipping_tax_total: NaN,  <<<<<<<<
gift_card_total: 0,
gift_card_tax_total: 0,
tax_total: NaN,   <<<<<<<<```
#

And looking at it deeper, this is NaN because it iterates over the shipping methods to calculate the total and the Shipping Method has NaNs in there:

```

ShippingMethod {
id: 'sm_01GY8FEJ7HBQP7JC0WSH9WBJ67',
shipping_option_id: 'so_01GSB9B275NWPHV2VM3EXQVF0H',
order_id: null,
claim_order_id: null,
cart_id: 'cart_01GY5QQ40V15E49WRR45D8HJ75',
swap_id: null,
return_id: null,
price: 0,
data: [Object],
tax_lines: [Array],
shipping_option: [ShippingOption],
original_total: NaN,
total: NaN,
subtotal: 0,
original_tax_total: NaN,
tax_total: NaN
}

idle tapir
#

Any thoughts on why there are NaNs when I add a shipping method?