#xxxxxxxxxxxx_api

1 messages ยท Page 1 of 1 (latest)

gilded radishBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1317087788390420522

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

formal shoal
#

๐Ÿ‘‹ happy to help

#

what are you trying to achieve?

lone spire
#

hey sorry didn't see your answer

#

I am trying to reverting a sub so I generate a 100% off coupon, it works most of the time but when testing for a new user a got this problem : coupon don't exist even if i just created it (as you can see with both request ids)

formal shoal
#

I think this is a race condition

#

the two requests are happening at the same time

#

I would just wait until the coupon is created before creating the subscription

lone spire
#

well that's what i am doing

#

coupon is created and awaited before updating the sub

formal shoal
#

would you mind sharing your code?

#

would you mind sharing the code for createStripeDiscountCoupon

lone spire
#

its a simple wrapper

#

okay thats all good

formal shoal
#

hmmm, I'm trying to see whether the idempotency is playing a role here

lone spire
#

when you said "race condition" it gave me information about maybe a double calling of the reverting update in my code

#

And that was the case

#

Thanks for your help ๐Ÿ™‚

formal shoal
#

sure let me know if you need any more help

lone spire
#

(i am deleting the code for security purpose)

#

Oh crap, it was not the issue

#

I misunderstood a part of the code, sorry.

#

Do you think idempotency can be the key to resolve the issue?

formal shoal
#

yes I think what's happening is the following

#

then you deleted it

#

when you do that, Stripe doesn't execute the request

#

instead it just returns the same response that you got the first time you requested this

lone spire
#

Oh yeah, if the update fails, I delete the coupon to not have a 100% off coupon living out there

#

So... What would be the good way to handle this?

formal shoal
#

just generate a new idempotency key

lone spire
#

everytime I create a coupon?

formal shoal
#

yes

lone spire
#

It worked (no doubt this time haha)

#

Thanks ๐Ÿ™‚