-
Notifications
You must be signed in to change notification settings - Fork 148
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
Retrying on any error from the Watch stream #70
Conversation
This ports the exponential backoff logic from the Firestore Mobile Web client.
Codecov Report
@@ Coverage Diff @@
## master #70 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 11 12 +1
Lines 1481 1524 +43
=====================================
+ Hits 1481 1524 +43
Continue to review full report at Codecov.
|
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.
Random nits as per usual. :-)
src/backoff.js
Outdated
const BACKOFF_FACTOR = 1.5; | ||
|
||
/*! | ||
* The jitter to distribute the backoff attempts by. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/backoff.js
Outdated
*/ | ||
|
||
/*! | ||
* Initial backoff time in milliseconds after an error. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/backoff.js
Outdated
const BACKOFF_INITIAL_DELAY_MS = 1000; | ||
|
||
/*! | ||
* Maximum backoff time in milliseconds. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/backoff.js
Outdated
const BACKOFF_MAX_DELAY_MS = 60 * 1000; | ||
|
||
/*! | ||
* The factor to increase the backup by after each failed attempt. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/backoff.js
Outdated
* This corresponds to | ||
* {@link https://github.com/grpc/grpc/blob/master/doc/statuscodes.md}. | ||
*/ | ||
const GRPC_STATUS_CODE = { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
function assertDelayBetween(low, high) { | ||
let actual = observedDelays.shift(); | ||
assert.ok(actual >= low); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/watch.js
Outdated
@@ -591,6 +597,8 @@ describe('Query watch', function() { | |||
}; | |||
|
|||
beforeEach(function() { | |||
Backoff.setTimeoutHandler(setImmediate); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/watch.js
Outdated
watchHelper.startWatch(); | ||
it("doesn't re-open inactive stream", function() { | ||
// This test uses the normal timeout handler since we unsubscribe from the | ||
// Watch stream while the stream is recovering from an error. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/watch.js
Outdated
@@ -986,7 +1058,7 @@ describe('Query watch', function() { | |||
streamHelper.writeStream.destroy(); | |||
}); | |||
}, | |||
'Error: Steam Error (6)' | |||
'Steam Error (6)' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/watch.js
Outdated
@@ -1809,13 +1881,19 @@ describe('DocumentReference watch', function() { | |||
}; | |||
|
|||
beforeEach(function() { | |||
Backoff.setTimeoutHandler(setImmediate); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Addressed all comments. Thanks @mikelehen |
LGTM. Sorry for the delay. |
@stephenplusplus Can you also look at this before I merge this? This adds retry semantics for Watch. |
LGTM. |
This ports the exponential backoff logic from the Firestore Mobile Web client.
Fixes firebase/firebase-admin-node#119