Skip to content
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

Minor: wrap the inner error on retried transactions and return when deadline exceeded #309

Merged
merged 18 commits into from
Aug 31, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"ycsb": "node ./benchmark/ycsb.js run -P ./benchmark/workloada -p table=usertable -p cloudspanner.instance=ycsb-instance -p operationcount=100 -p cloudspanner.database=ycsb"
},
"dependencies": {
"@google-cloud/common": "^0.23.0",

This comment was marked as spam.

"@google-cloud/common-grpc": "^0.7.1",
"@google-cloud/paginator": "^0.1.0",
"@google-cloud/projectify": "^0.3.0",
Expand Down
15 changes: 11 additions & 4 deletions src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'use strict';

const {promisifyAll} = require('@google-cloud/promisify');
const common = require('@google-cloud/common');
const extend = require('extend');
const gax = require('google-gax');
const is = require('is');
Expand All @@ -40,6 +41,11 @@ const TransactionRequest = require('./transaction-request');
*/
const UNKNOWN = 2;

/**
* the gRPC `DEADLINE_EXCEEDED` error code.
*/
const DEADLINE_EXCEEDED = 4;

/**
* The gRPC `ABORTED` error code.
*
Expand Down Expand Up @@ -720,10 +726,11 @@ class Transaction extends TransactionRequest {
* @return {object}
*/
static createDeadlineError_(err) {
return extend({}, err, {
code: 4,
message: 'Deadline for Transaction exceeded.',
});
let apiError = new common.util.ApiError('Deadline for Transaction exceeded.')
apiError.code = DEADLINE_EXCEEDED
apiError.errors.push(err)

return apiError;
}
/**
* Extracts retry delay and formats into milliseconds.
Expand Down