#mattwoberts
1 messages · Page 1 of 1 (latest)
Hi there!
Hi!
Yes that's correct as mentioned here:
While the idempotency-cached response to those requests won’t change, we’ll try to fire webhooks for any new objects created as part of Stripe’s reconciliation.
https://stripe.com/docs/error-low-level#server-errors
boo
Hi 🙂
hi soma, just merging my thread with this one
Hang on - even if the 500 was caused by a glitch on stripe's side, say a network glitch?
Surely not?
if you cache 500 responses what's the value of the maxnetworkretries property in the sdk? if it always returns the cached response then retrying is pointless?
I think there's some misunderstanding - perhaps @mighty raven means that you will get a 500 if the issue is caused by some error caused by your stripe request - something that's not possible? 'Cos if Stripe had an issue, and couldn't service your request, I can't imagine it would cache that response and just serve it up again?
ah - actually I've just read that link and it looks like that is the case, the idempotency layuer DOES cache it.... wow.
I recommend you to read the link I shared earlier, that covers this https://stripe.com/docs/error-low-level#server-errors
As with user errors, the idempotency layer caches the result of POST mutations that result in server errors (specifically 500s, which are internal server errors), so retrying them with the same idempotency key usually produces the same result.
so can you use the sdk to retry forever without using an idempotency key?
yeah if you don't set a idempotency key it will try again from the looks of it.
This is news to me - I'm going to have to go and review my own code!
@torpid moon - docs say "Most client libraries can generate idempotency keys and retry requests automatically, but you need to configure it. For finer-grained control over retries, generate idempotency keys and write your own logic for retries."
@torpid moon Presumably you've read this too https://github.com/stripe/stripe-dotnet#automatic-retries
Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for stripe.com. - GitHub - stripe/stripe-dotnet: Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class libr...
nope, just that video, i was using polly until last night to handle retries. the video said you can set the maxnumberofretries property but it also implies it sets the key too which is not what you'd want
@torpid moon Ok cool - not really sure I helped here, or if I just got in the way 😉 I'm going to check out my own code though, I'm pretty sure we pulled it out of polly 'cos of the built in retry stuff
if you set maxnumberofretries and it sets a key automaticlly but stripe returns a 500 it won't retry as you'd hope
so you're better off with polly from my naive understanding
I think the MaxNetworkRetries setting will use the same idempotency key when retrying a request.
But in general this is what we recommend when getting a 500 error:
- Treat requests that return 500 errors as indeterminate
- Use webhook events to know if the request succeeded or not
Thanks @mighty raven
there's a chance you get a 500 but it worked?
there's a chance you get a 500 but it worked?
Correct.
🤦♂️
Again, all of this is covered in the link I shared earlier https://stripe.com/docs/error-low-level#server-errors
You should treat the result of a 500 request as indeterminate. The most likely time to observe one is during a production incident, and generally during such an incident’s remediation Stripe engineers examine failed requests and try to appropriately reconcile the results of any mutations that result in 500s.
Stripe engineers examine failed requests and try to appropriately reconcile the results of any mutations that result in 500s so your engineers will see the failed request but see then intent of it and try and action it anyway?
ie/make a charge request, prod incident, 500 response, engineer sees what the intent was, makes the adjustment on the server, issues a webhook to say it succeeded?
ie/make a charge request, prod incident, 500 response, engineer sees what the intent was, makes the adjustment on the server, issues a webhook to say it succeeded?
Yes, exactly, this can happen.
hmm, going to have to have a think on this then, i would rather retry the 500 request until I get a 200 not listen to webhooks to determine if it was a success
i would rather retry the 500 request until I get a 200
Unfortunately that's not possible, since retrying the 500 with the same idempotency keys will always return a 500. And if you change the idempotency keys, then you run the risks of successfully doing the same request multiple times in a row.
well if there is no key or different keys you see a 500 and then try again until a 200, i don't see how you'd end up with multiple successful requests?
500-500-500-200-stop
If you retry the same 500 with different API keys, then Stripe could fix the issue later and all the previous 500 will actually be executed correctly.
so if i have one request to make a charge of $10 and stripe has a prod issue and i get 3 500 responses and then a 200, you're saying that instead of 1 $10 charge, your engineers will try and fix the failed requests and that 1 customer would be charged $40 instead of $10?
Yes, that's why you should use the same idempotency key when retrying a 500 request. This way Stripe know it's the same request and the customer would be only charged $10 once.
but in the case of a 500 with the same key we'll always get a 500 right? we'd never get a 200
Yes correct.
so most devs would try the request again with a new key
but you're saying it's best not to retry a 500 because the engineers will fix it on the backend?
👋 taking over for my colleague. Let me catch up.
I don't really follow the Q
hi, above it was mentioned that stripe engineers in the case of a prod incident and clients get 500s will look at the failed requests and try to manually fix the issue and so if a dev sees a 500 and tries 10 times to make the request succeed, and on the 10th request it does succeed the stripe engineers will make a charge 10 times instead of 1
but you're saying it's best not to retry a 500 because the engineers will fix it on the backend?
You can retry 500, but with the same idempotency key. Also note that 500 error won't always be fixed, it depends. That's why the doc says to treat them as indeterminate.
but there's no point retrying a 500 with the same key as it says it will return the cached response on subsequent requests
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!
I guess just to clarify, that i believe my setup should be to retry over and over any 4xx status codes, not to retry 5xx status codes but check the webhooks to see if something did eventually succeed due to an engineer possibly fixing it. i now have to work out a correlation between failed requests and webhooks and then a timer to know when to manually try again if a stripe engineer didnt fix it
believe my setup should be to retry over and over any 4xx status codes,
Yes,4xxare safe to retry as they're a user error
Indeed, handling 500 errors is difficult and as such you should treat them as indeterminate and attempt reconciliation via the events that may eventually fire to indicate success/failure
Obviously we try to keep these errors to a minimum, but they can/do happen unfortunately and your integration should be prepared for that