@google-cloud/spanner 7.9.0 → 7.9.1
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
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
[1]: https://www.npmjs.com/package/nodejs-spanner?activeTab=versions
|
|
6
6
|
|
|
7
|
+
## [7.9.1](https://github.com/googleapis/nodejs-spanner/compare/v7.9.0...v7.9.1) (2024-06-26)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* Retry with timeout ([#2071](https://github.com/googleapis/nodejs-spanner/issues/2071)) ([a943257](https://github.com/googleapis/nodejs-spanner/commit/a943257a0402b26fd80196057a9724fd28fc5c1b))
|
|
13
|
+
|
|
7
14
|
## [7.9.0](https://github.com/googleapis/nodejs-spanner/compare/v7.8.0...v7.9.0) (2024-06-21)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Readable, Transform } from 'stream';
|
|
17
|
+
import { CallOptions } from 'google-gax';
|
|
17
18
|
import { JSONOptions, Json, Field, Value } from './codec';
|
|
18
19
|
import { google } from '../protos/protos';
|
|
19
20
|
export type ResumeToken = string | Uint8Array;
|
|
@@ -81,6 +82,7 @@ export interface RowOptions {
|
|
|
81
82
|
* };
|
|
82
83
|
*/
|
|
83
84
|
columnsMetadata?: object;
|
|
85
|
+
gaxOptions?: CallOptions;
|
|
84
86
|
}
|
|
85
87
|
/**
|
|
86
88
|
* By default rows are an Array of values in the form of objects containing
|
|
@@ -284,10 +284,13 @@ exports.PartialResultStream = PartialResultStream;
|
|
|
284
284
|
* @returns {PartialResultStream}
|
|
285
285
|
*/
|
|
286
286
|
function partialResultStream(requestFn, options) {
|
|
287
|
+
var _a, _b;
|
|
287
288
|
const retryableCodes = [google_gax_1.grpc.status.UNAVAILABLE];
|
|
288
289
|
const maxQueued = 10;
|
|
289
290
|
let lastResumeToken;
|
|
290
291
|
let lastRequestStream;
|
|
292
|
+
const startTime = Date.now();
|
|
293
|
+
const timeout = (_b = (_a = options === null || options === void 0 ? void 0 : options.gaxOptions) === null || _a === void 0 ? void 0 : _a.timeout) !== null && _b !== void 0 ? _b : Infinity;
|
|
291
294
|
// mergeStream allows multiple streams to be connected into one. This is good;
|
|
292
295
|
// if we need to retry a request and pipe more data to the user's stream.
|
|
293
296
|
// We also add an additional stream that can be used to flush any remaining
|
|
@@ -336,6 +339,14 @@ function partialResultStream(requestFn, options) {
|
|
|
336
339
|
requestsStream.add(lastRequestStream);
|
|
337
340
|
};
|
|
338
341
|
const retry = (err) => {
|
|
342
|
+
const elapsed = Date.now() - startTime;
|
|
343
|
+
if (elapsed >= timeout) {
|
|
344
|
+
// The timeout has reached so this will flush any rows the
|
|
345
|
+
// checkpoint stream has queued. After that, we will destroy the
|
|
346
|
+
// user's stream with the Deadline exceeded error.
|
|
347
|
+
setImmediate(() => batchAndSplitOnTokenStream.destroy(new transaction_runner_1.DeadlineError(err)));
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
339
350
|
if (!(err.code &&
|
|
340
351
|
(retryableCodes.includes(err.code) || (0, transaction_runner_1.isRetryableInternalError)(err))) ||
|
|
341
352
|
// If we have received too many chunks without a resume token, it is not
|
package/build/src/transaction.js
CHANGED
|
@@ -410,6 +410,7 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
410
410
|
jsonOptions,
|
|
411
411
|
maxResumeRetries,
|
|
412
412
|
columnsMetadata,
|
|
413
|
+
gaxOptions,
|
|
413
414
|
})) === null || _c === void 0 ? void 0 : _c.on('response', response => {
|
|
414
415
|
if (response.metadata && response.metadata.transaction && !this.id) {
|
|
415
416
|
this._update(response.metadata.transaction);
|
|
@@ -677,6 +678,7 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
677
678
|
jsonOptions,
|
|
678
679
|
maxResumeRetries,
|
|
679
680
|
columnsMetadata,
|
|
681
|
+
gaxOptions,
|
|
680
682
|
})
|
|
681
683
|
.on('response', response => {
|
|
682
684
|
if (response.metadata && response.metadata.transaction && !this.id) {
|