@proteinjs/db 1.53.0 → 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/test/index.js +1 -1
- package/dist/generated/test/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/src/Db.d.ts +45 -5
- package/dist/src/Db.d.ts.map +1 -1
- package/dist/src/Db.js +45 -11
- package/dist/src/Db.js.map +1 -1
- package/dist/src/TransactionRetryExhaustedError.d.ts +25 -0
- package/dist/src/TransactionRetryExhaustedError.d.ts.map +1 -0
- package/dist/src/TransactionRetryExhaustedError.js +54 -0
- package/dist/src/TransactionRetryExhaustedError.js.map +1 -0
- package/dist/src/transaction/TransactionRetryPolicy.d.ts +34 -0
- package/dist/src/transaction/TransactionRetryPolicy.d.ts.map +1 -0
- package/dist/src/transaction/TransactionRetryPolicy.js +3 -0
- package/dist/src/transaction/TransactionRetryPolicy.js.map +1 -0
- package/dist/test/TransactionRetryOptions.test.d.ts +2 -0
- package/dist/test/TransactionRetryOptions.test.d.ts.map +1 -0
- package/dist/test/TransactionRetryOptions.test.js +293 -0
- package/dist/test/TransactionRetryOptions.test.js.map +1 -0
- package/generated/index.ts +1 -1
- package/generated/test/index.ts +1 -1
- package/index.ts +2 -0
- package/package.json +2 -2
- package/src/Db.ts +72 -11
- package/src/TransactionRetryExhaustedError.ts +37 -0
- package/src/transaction/TransactionRetryPolicy.ts +31 -0
- package/test/TransactionRetryOptions.test.ts +195 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a transaction is re-run when the database ABORTS it — a lock conflict the database
|
|
3
|
+
* resolves by aborting one of the transactions in it, delivered at that transaction's next
|
|
4
|
+
* statement or at its commit. The policy is the CALLER's, named at the call, never a default a
|
|
5
|
+
* caller cannot see:
|
|
6
|
+
*
|
|
7
|
+
* - Omitted: the driver's own road — the one right for a durable write, which must land however
|
|
8
|
+
* long the conflict lasts (on Spanner, the client library's runner re-runs the body on its
|
|
9
|
+
* backoff ladder inside the driver's configured budget).
|
|
10
|
+
* - `'none'`: one attempt. The abort reaches the caller at once, typed
|
|
11
|
+
* (`TransactionRetryExhaustedError`).
|
|
12
|
+
* - `{ attempts, maxMs }`: at most `attempts` attempts in all (the first included), and no
|
|
13
|
+
* attempt starts once `maxMs` milliseconds have passed since the first began; when either
|
|
14
|
+
* bound is reached the last abort reaches the caller typed. `maxMs` omitted bounds by
|
|
15
|
+
* attempts alone.
|
|
16
|
+
*
|
|
17
|
+
* A BEST-EFFORT write names a bounded policy: a write that the next write of its kind supersedes
|
|
18
|
+
* anyway (a live progress row rewritten at every step) must not be re-run for minutes against a
|
|
19
|
+
* conflict it will lose — it loses promptly, and the caller handles the typed refusal.
|
|
20
|
+
*
|
|
21
|
+
* The policy belongs to a transaction: a write issued outside any transaction is a transaction
|
|
22
|
+
* of its own and names it at the write (`Db.insert`, `Db.update`); a `Db.runTransaction` body
|
|
23
|
+
* names it on the transaction, and every write inside that body rides it — a write inside a
|
|
24
|
+
* transaction cannot name a policy of its own.
|
|
25
|
+
*/
|
|
26
|
+
export type TransactionRetryPolicy = 'none' | {
|
|
27
|
+
attempts: number;
|
|
28
|
+
maxMs?: number;
|
|
29
|
+
};
|
|
30
|
+
/** The options of a transaction — a `Db.runTransaction` body's, or a write's own when it runs outside one. */
|
|
31
|
+
export type TransactionOptions = {
|
|
32
|
+
retry?: TransactionRetryPolicy;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=TransactionRetryPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/transaction/TransactionRetryPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnF,8GAA8G;AAC9G,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,sBAAsB,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionRetryPolicy.js","sourceRoot":"","sources":["../../../src/transaction/TransactionRetryPolicy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionRetryOptions.test.d.ts","sourceRoot":"","sources":["../../test/TransactionRetryOptions.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var reflection_1 = require("@proteinjs/reflection");
|
|
55
|
+
var Db_1 = require("../src/Db");
|
|
56
|
+
var Table_1 = require("../src/Table");
|
|
57
|
+
var Record_1 = require("../src/Record");
|
|
58
|
+
var Columns_1 = require("../src/Columns");
|
|
59
|
+
var TableWatcherRunner_1 = require("../src/TableWatcherRunner");
|
|
60
|
+
var TransactionRetryExhaustedError_1 = require("../src/TransactionRetryExhaustedError");
|
|
61
|
+
var DocTable = /** @class */ (function (_super) {
|
|
62
|
+
__extends(DocTable, _super);
|
|
63
|
+
function DocTable() {
|
|
64
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
65
|
+
_this.name = 'retry_options_doc';
|
|
66
|
+
_this.columns = (0, Record_1.withRecordColumns)({
|
|
67
|
+
title: new Columns_1.StringColumn('title'),
|
|
68
|
+
});
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
return DocTable;
|
|
72
|
+
}(Table_1.Table));
|
|
73
|
+
var docTable = new DocTable();
|
|
74
|
+
var TestTransactionContextFactory = /** @class */ (function () {
|
|
75
|
+
function TestTransactionContextFactory() {
|
|
76
|
+
this.context = {};
|
|
77
|
+
}
|
|
78
|
+
TestTransactionContextFactory.prototype.getTransactionContext = function () {
|
|
79
|
+
return this.context;
|
|
80
|
+
};
|
|
81
|
+
TestTransactionContextFactory.prototype.runInContext = function (context, fn) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var previous;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
previous = this.context;
|
|
88
|
+
this.context = context;
|
|
89
|
+
_a.label = 1;
|
|
90
|
+
case 1:
|
|
91
|
+
_a.trys.push([1, , 3, 4]);
|
|
92
|
+
return [4 /*yield*/, fn()];
|
|
93
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
94
|
+
case 3:
|
|
95
|
+
this.context = previous;
|
|
96
|
+
return [7 /*endfinally*/];
|
|
97
|
+
case 4: return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
return TestTransactionContextFactory;
|
|
103
|
+
}());
|
|
104
|
+
/** A driver that records the transaction and options every write and transaction arrived with. */
|
|
105
|
+
var RecordingDriver = /** @class */ (function () {
|
|
106
|
+
function RecordingDriver() {
|
|
107
|
+
this.dmlCalls = [];
|
|
108
|
+
this.transactionCalls = [];
|
|
109
|
+
}
|
|
110
|
+
RecordingDriver.prototype.getDbName = function () {
|
|
111
|
+
return 'test';
|
|
112
|
+
};
|
|
113
|
+
RecordingDriver.prototype.createDbIfNotExists = function () {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
115
|
+
return [2 /*return*/];
|
|
116
|
+
}); });
|
|
117
|
+
};
|
|
118
|
+
RecordingDriver.prototype.createDb = function () {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
120
|
+
return [2 /*return*/];
|
|
121
|
+
}); });
|
|
122
|
+
};
|
|
123
|
+
RecordingDriver.prototype.dropDb = function () {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
125
|
+
return [2 /*return*/];
|
|
126
|
+
}); });
|
|
127
|
+
};
|
|
128
|
+
RecordingDriver.prototype.getTableManager = function () {
|
|
129
|
+
throw new Error('not used by these tests');
|
|
130
|
+
};
|
|
131
|
+
RecordingDriver.prototype.runQuery = function () {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
return [2 /*return*/, []];
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
RecordingDriver.prototype.runDml = function (generateStatement, transaction, options) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
+
return __generator(this, function (_a) {
|
|
141
|
+
generateStatement({
|
|
142
|
+
useParams: true,
|
|
143
|
+
useNamedParams: true,
|
|
144
|
+
prefixTablesWithDb: false,
|
|
145
|
+
getDriverColumnType: function () { return 'STRING(MAX)'; },
|
|
146
|
+
});
|
|
147
|
+
this.dmlCalls.push({ transaction: transaction, options: options });
|
|
148
|
+
return [2 /*return*/, 1];
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
RecordingDriver.prototype.runTransaction = function (fn, options) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0:
|
|
157
|
+
this.transactionCalls.push({ options: options });
|
|
158
|
+
return [4 /*yield*/, fn({ handle: 'the transaction' })];
|
|
159
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
RecordingDriver.prototype.getOperationDeadlineMs = function () {
|
|
165
|
+
return 60000;
|
|
166
|
+
};
|
|
167
|
+
return RecordingDriver;
|
|
168
|
+
}());
|
|
169
|
+
var objectCache = function () { return reflection_1.SourceRepository.get().objectCache; };
|
|
170
|
+
describe('A write names its retry policy at the call; it reaches the driver on the write`s own transaction', function () {
|
|
171
|
+
var driver;
|
|
172
|
+
var db;
|
|
173
|
+
var originalWatchers;
|
|
174
|
+
// No reflection graph in a unit test: the watcher registry is empty by declaration.
|
|
175
|
+
beforeAll(function () {
|
|
176
|
+
originalWatchers = objectCache()['@proteinjs/db/TableWatcher'];
|
|
177
|
+
objectCache()['@proteinjs/db/TableWatcher'] = [];
|
|
178
|
+
TableWatcherRunner_1.TableWatcherRunner.tableWatcherMap = undefined;
|
|
179
|
+
});
|
|
180
|
+
afterAll(function () {
|
|
181
|
+
if (originalWatchers) {
|
|
182
|
+
objectCache()['@proteinjs/db/TableWatcher'] = originalWatchers;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
delete objectCache()['@proteinjs/db/TableWatcher'];
|
|
186
|
+
}
|
|
187
|
+
TableWatcherRunner_1.TableWatcherRunner.tableWatcherMap = undefined;
|
|
188
|
+
});
|
|
189
|
+
beforeEach(function () {
|
|
190
|
+
driver = new RecordingDriver();
|
|
191
|
+
db = new Db_1.Db(driver, function () { return docTable; }, new TestTransactionContextFactory(), true);
|
|
192
|
+
});
|
|
193
|
+
test('an update outside a transaction carries its policy to the driver, with no transaction', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
194
|
+
return __generator(this, function (_a) {
|
|
195
|
+
switch (_a.label) {
|
|
196
|
+
case 0: return [4 /*yield*/, db.update(docTable, { id: 'doc-1', title: 'a title' }, undefined, { retry: { attempts: 2, maxMs: 1500 } })];
|
|
197
|
+
case 1:
|
|
198
|
+
_a.sent();
|
|
199
|
+
expect(driver.dmlCalls).toEqual([{ transaction: undefined, options: { retry: { attempts: 2, maxMs: 1500 } } }]);
|
|
200
|
+
return [2 /*return*/];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}); });
|
|
204
|
+
test('an insert outside a transaction carries its policy to the driver, with no transaction', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
205
|
+
return __generator(this, function (_a) {
|
|
206
|
+
switch (_a.label) {
|
|
207
|
+
case 0: return [4 /*yield*/, db.insert(docTable, { title: 'a title' }, { retry: 'none' })];
|
|
208
|
+
case 1:
|
|
209
|
+
_a.sent();
|
|
210
|
+
expect(driver.dmlCalls).toEqual([{ transaction: undefined, options: { retry: 'none' } }]);
|
|
211
|
+
return [2 /*return*/];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}); });
|
|
215
|
+
test('a write with no policy reaches the driver with none — the driver`s own road', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
216
|
+
return __generator(this, function (_a) {
|
|
217
|
+
switch (_a.label) {
|
|
218
|
+
case 0: return [4 /*yield*/, db.update(docTable, { id: 'doc-1', title: 'a title' })];
|
|
219
|
+
case 1:
|
|
220
|
+
_a.sent();
|
|
221
|
+
return [4 /*yield*/, db.insert(docTable, { title: 'a title' })];
|
|
222
|
+
case 2:
|
|
223
|
+
_a.sent();
|
|
224
|
+
expect(driver.dmlCalls.map(function (call) { return call.options; })).toEqual([undefined, undefined]);
|
|
225
|
+
return [2 /*return*/];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}); });
|
|
229
|
+
test('a transaction carries its policy to the driver, and the writes inside it ride the transaction with no policy of their own', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0: return [4 /*yield*/, db.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
233
|
+
return __generator(this, function (_a) {
|
|
234
|
+
switch (_a.label) {
|
|
235
|
+
case 0: return [4 /*yield*/, db.update(docTable, { id: 'doc-1', title: 'a title' })];
|
|
236
|
+
case 1:
|
|
237
|
+
_a.sent();
|
|
238
|
+
return [4 /*yield*/, db.insert(docTable, { title: 'a title' })];
|
|
239
|
+
case 2:
|
|
240
|
+
_a.sent();
|
|
241
|
+
return [2 /*return*/];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}); }, { retry: { attempts: 3 } })];
|
|
245
|
+
case 1:
|
|
246
|
+
_a.sent();
|
|
247
|
+
expect(driver.transactionCalls).toEqual([{ options: { retry: { attempts: 3 } } }]);
|
|
248
|
+
expect(driver.dmlCalls).toEqual([
|
|
249
|
+
{ transaction: { handle: 'the transaction' }, options: undefined },
|
|
250
|
+
{ transaction: { handle: 'the transaction' }, options: undefined },
|
|
251
|
+
]);
|
|
252
|
+
return [2 /*return*/];
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}); });
|
|
256
|
+
test('a write inside a transaction naming a policy of its own is refused by name, and never reaches the driver', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
257
|
+
var refusal;
|
|
258
|
+
return __generator(this, function (_a) {
|
|
259
|
+
switch (_a.label) {
|
|
260
|
+
case 0:
|
|
261
|
+
refusal = db.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
262
|
+
return __generator(this, function (_a) {
|
|
263
|
+
switch (_a.label) {
|
|
264
|
+
case 0: return [4 /*yield*/, db.update(docTable, { id: 'doc-1', title: 'a title' }, undefined, { retry: 'none' })];
|
|
265
|
+
case 1:
|
|
266
|
+
_a.sent();
|
|
267
|
+
return [2 /*return*/];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}); });
|
|
271
|
+
return [4 /*yield*/, expect(refusal).rejects.toThrow('A write inside a transaction cannot name a retry policy of its own')];
|
|
272
|
+
case 1:
|
|
273
|
+
_a.sent();
|
|
274
|
+
expect(driver.dmlCalls).toEqual([]);
|
|
275
|
+
return [2 /*return*/];
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}); });
|
|
279
|
+
test('the typed refusal: name-tagged, carrying the attempts and the elapsed time, its cause never enumerable', function () {
|
|
280
|
+
var abort = new Error('10 ABORTED: the backend quotes a row value here');
|
|
281
|
+
var refusal = new TransactionRetryExhaustedError_1.TransactionRetryExhaustedError('spanner dml transaction', 2, 312.4, abort);
|
|
282
|
+
expect((0, TransactionRetryExhaustedError_1.isTransactionRetryExhaustedError)(refusal)).toBe(true);
|
|
283
|
+
expect((0, TransactionRetryExhaustedError_1.isTransactionRetryExhaustedError)(new Error('other'))).toBe(false);
|
|
284
|
+
expect(refusal.name).toBe('TransactionRetryExhaustedError');
|
|
285
|
+
expect(refusal.attempts).toBe(2);
|
|
286
|
+
expect(refusal.elapsedMs).toBe(312.4);
|
|
287
|
+
expect(refusal.cause).toBe(abort);
|
|
288
|
+
expect(Object.keys(refusal)).not.toContain('cause');
|
|
289
|
+
expect(JSON.stringify(refusal)).not.toContain('row value');
|
|
290
|
+
expect(refusal.message).toBe('Transaction aborted and not retried further: its retry policy allowed 2 attempts, made in 312ms (spanner dml transaction)');
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
//# sourceMappingURL=TransactionRetryOptions.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionRetryOptions.test.js","sourceRoot":"","sources":["../../test/TransactionRetryOptions.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAyD;AAEzD,gCAAqE;AACrE,sCAAqC;AACrC,wCAA0D;AAC1D,0CAA8C;AAC9C,gEAA+D;AAG/D,wFAG+C;AAiB/C;IAAuB,4BAAU;IAAjC;QAAA,qEAKC;QAJQ,UAAI,GAAG,mBAAmB,CAAC;QAC3B,aAAO,GAAG,IAAA,0BAAiB,EAAM;YACtC,KAAK,EAAE,IAAI,sBAAY,CAAC,OAAO,CAAC;SACjC,CAAC,CAAC;;IACL,CAAC;IAAD,eAAC;AAAD,CAAC,AALD,CAAuB,aAAK,GAK3B;AAED,IAAM,QAAQ,GAAG,IAAI,QAAQ,EAAgB,CAAC;AAE9C;IAAA;QACU,YAAO,GAA2B,EAAE,CAAC;IAe/C,CAAC;IAbC,6DAAqB,GAArB;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEK,oDAAY,GAAlB,UAAsB,OAA+B,EAAE,EAAoB;;;;;;wBACnE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;wBAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;;;;wBAEd,qBAAM,EAAE,EAAE,EAAA;4BA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