-
Notifications
You must be signed in to change notification settings - Fork 104
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
fixes #202 by retrying on an UNKNOWN error code #212
Conversation
A unit test for this would be lovely :) |
Codecov Report
@@ Coverage Diff @@
## master #212 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 12 12
Lines 1385 1388 +3
=====================================
+ Hits 1385 1388 +3
Continue to review full report at Codecov.
|
@JustinBeckwith , sure I thought about duplicating the one we have for errcode 10 so easy to add :) |
* @param {number} errCode - the error code | ||
* @return {boolean} | ||
*/ | ||
Transaction.prototype.isRetryableErrorCode_ = function(errCode) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* | ||
* @param {error} err - The request error. | ||
* @return {boolean} | ||
*/ | ||
Transaction.prototype.shouldRetry_ = function(err) { | ||
return ( | ||
err.code === ABORTED && | ||
this.isRetryableErrorCode_(err.code) && |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/transaction.js
Outdated
@@ -725,7 +725,39 @@ describe('Transaction', function() { | |||
fakeStream.emit('error', error); | |||
}); | |||
|
|||
it('should retry the transaction', function(done) { | |||
it('should retry the transaction for UNKNOWN', function(done) { |
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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -403,7 +410,7 @@ Transaction.prototype.request = function(config, callback) { | |||
); | |||
|
|||
this.session.request(config, function(err, resp) { | |||
if (!self.runFn_ || !err || err.code !== ABORTED) { | |||
if (!self.runFn_ || !err || !self.isRetryableErrorCode_(err.code)) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Subject to review, but all comments were about expanding testing, which I have addressed.
Fixes #202