#JACKSON

1 messages · Page 1 of 1 (latest)

cosmic oreBOT
icy crag
#

Or if your system set idempotency on your own in the request, it can also create a new request ID, but only perform the operation once from the previous request.

dusk compass
#

So if I wanted it to not re-try and instead error out if the request fails, I would just need to set Stripe.max_network_retries to 0?

icy crag
#

By default, Stripe.max_network_retries is 0 (no retry) if your code didn't configure it

dusk compass
#

I didn't have it configured, so should it not have retried it then?

icy crag
#

Did you server configure idempotency with your own internal retry system?

dusk compass
#

no we do not

#

we don't send idempotency keys.

Just make the call to the .create method and then rescue a Stripe::StripeError in the method

subscription = Stripe::Subscription.create(data)

icy crag
#

This is likely that the library has other retry mechanism. With idempotency key, the request will only have the operation once and it shouldn't affect your integration. Did you face any issue with this?

dusk compass
#

yeah what happened is it looks like it retried the request but the retry was outside of the execution of our code so it was unable to save the data from the successful response. hence the subscription's ID did not get saved to our database and was therefore lost

icy crag
#

req_GdG7PEqTfLNXTSt was replayed and the response had the same subscription ID as req_oJofDf7RbgmJmk. If your code handled the response of subscription correctly, either of them will have the same subscription ID

dusk compass
#

when its "replayed", does it behave like a single API call? like from start to finish its only executing once?

cosmic oreBOT
wild galleon
#

yes, you can test this out yourself if you want to see how it works

dusk compass
#

Nonetheless, I am curious why it still retried even though river said by default its set to 0 (no retry). We don't have any overrides in the initializer to specify otherwise.

wild galleon
#

the only possible reason here is that network retries have been set somewhere in your code, maybe you'd want to take some time to look through it again?

dusk compass
#

Loading development environment (Rails 7.0.4.3)
2.7.7 :001 > Stripe.max_network_retries

#

=> 0

#

our max network retries is set at 0

#

Also, why was the request retried if both of them responded with a 200 code?

icy crag
#

If there is connection issue such as timeout that the response isn't returned in time (even though it's successful), it might retry to get the response for the previous request