-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Network retries #559
Network retries #559
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some quick high level comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stopping review for now, thought I'd share these comments
ptal @paulasjes-stripe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, have a basket of nits! I still have to review tests, but won't be able to get to that right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great! Few further nits on tests etc, pretty sure this should be ready to ship thereafter!
ptal @paulasjes-stripe
}); | ||
|
||
describe('_getSleepTimeInMS', function() { | ||
it('should not exceed the maximum or minimum values', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call me a cranky fellow, but having randomness/fuzzing in tests like this makes me uncomfortable (even though I expect it to pass in all cases). Imagine we had an exceedingly rare edge-case bug, such as failing when Math.random()
produces exactly 0.0
- it'd occasionally fail in CI, which is frustrating. Not the end of the world in stripe-node (we can just hit rebuild, and it doesn't block other things from getting released).
To be honest, I'm not sure this test is that important; thoughts on just deleting it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I think it's still useful to ensure that the sleep time is a value we'd expect.
I'd prefer a test that very rarely fails over a edge-case bug over never finding the edge-case bug at all. Especially since the Math.random()
call is in our production code and not in the test. Also it's nice to have more code coverage.
@ob-stripe Done! We now mock |
Nice! Thanks @paulasjes-stripe. Reassigning to @brandur-stripe and @rattrayalex-stripe for the final decision regarding the exact retry conditions, but this looks nearly ready to 🚢 |
Okay, Alex and I had a long talk over lunch following a long talk yesterday, and we've decided to not retry on 429s for the time being, but allowing for a system that eventually does pending a few server-side improvements that we'd like to make. I just pushed a commit to take 429s out of the retry equation. r? @rattrayalex-stripe Mind taking a quick look at that? Thanks! |
(Also, just wanted to note that I'm really happy to see this come into stripe-node. Thanks for the implementation @paulasjes-stripe!) |
@rattrayalex-stripe re-assigning to you to release! |
Can we squash the commits before merging please? :) |
Thanks for the reminder - will squash and merge before releasing sometime later today. |
r? @rattrayalex-stripe
cc @stripe/api-libraries
Fixes #558
Adds network retry functionality. The default retry amount is 0 but can be changed via
stripe.setMaxNetworkRetries(n)
. I modeled this after a similar change instripe-php
: https://github.com/stripe/stripe-php/pull/428/filesIn the case of a
POST
request, an idempotency key is generated if not already provided.This also adds the
uuid
andnock
libraries. The former is for generating idempotency keys, there already is a similar function used in testing however according to our docs [0]uuid/v4
should ideally be used for real requests. I usenock
to mock API responses and failures.[0]: https://stripe.com/docs/api/idempotent_requests