@google-cloud/spanner 5.16.3 → 5.17.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.
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2021 Google LLC
2
+ // Copyright 2022 Google LLC
3
3
  //
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.SpannerClient = void 0;
21
21
  /* global window */
22
22
  const gax = require("google-gax");
23
+ const google_gax_1 = require("google-gax");
24
+ const stream_1 = require("stream");
23
25
  const jsonProtos = require("../../protos/protos.json");
24
26
  /**
25
27
  * Client JSON configuration object, loaded from
@@ -199,6 +201,13 @@ class SpannerClient {
199
201
  for (const methodName of spannerStubMethods) {
200
202
  const callPromise = this.spannerStub.then(stub => (...args) => {
201
203
  if (this._terminated) {
204
+ if (methodName in this.descriptors.stream) {
205
+ const stream = new stream_1.PassThrough();
206
+ setImmediate(() => {
207
+ stream.emit('error', new google_gax_1.GoogleError('The client has already been closed.'));
208
+ });
209
+ return stream;
210
+ }
202
211
  return Promise.reject('The client has already been closed.');
203
212
  }
204
213
  const func = stub[methodName];
@@ -583,8 +592,6 @@ class SpannerClient {
583
592
  * Please see the
584
593
  * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming)
585
594
  * for more details and examples.
586
- * @example <caption>include:samples/generated/v1/spanner.execute_streaming_sql.js</caption>
587
- * region_tag:spanner_v1_generated_Spanner_ExecuteStreamingSql_async
588
595
  */
589
596
  executeStreamingSql(request, options) {
590
597
  request = request || {};
@@ -659,8 +666,6 @@ class SpannerClient {
659
666
  * Please see the
660
667
  * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming)
661
668
  * for more details and examples.
662
- * @example <caption>include:samples/generated/v1/spanner.streaming_read.js</caption>
663
- * region_tag:spanner_v1_generated_Spanner_StreamingRead_async
664
669
  */
665
670
  streamingRead(request, options) {
666
671
  request = request || {};
@@ -780,8 +785,6 @@ class SpannerClient {
780
785
  * Please see the
781
786
  * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
782
787
  * for more details and examples.
783
- * @example <caption>include:samples/generated/v1/spanner.list_sessions.js</caption>
784
- * region_tag:spanner_v1_generated_Spanner_ListSessions_async
785
788
  */
786
789
  listSessionsAsync(request, options) {
787
790
  request = request || {};
@@ -909,8 +912,7 @@ class SpannerClient {
909
912
  * @returns {Promise} A promise that resolves when the client is closed.
910
913
  */
911
914
  close() {
912
- this.initialize();
913
- if (!this._terminated) {
915
+ if (this.spannerStub && !this._terminated) {
914
916
  return this.spannerStub.then(stub => {
915
917
  this._terminated = true;
916
918
  stub.close();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@google-cloud/spanner",
3
3
  "description": "Cloud Spanner Client Library for Node.js",
4
- "version": "5.16.3",
4
+ "version": "5.17.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {
@@ -76,7 +76,7 @@
76
76
  },
77
77
  "devDependencies": {
78
78
  "@grpc/proto-loader": "^0.6.0",
79
- "@types/concat-stream": "^1.6.0",
79
+ "@types/concat-stream": "^2.0.0",
80
80
  "@types/extend": "^3.0.0",
81
81
  "@types/is": "0.0.21",
82
82
  "@types/lodash.snakecase": "^4.1.4",
@@ -108,7 +108,7 @@
108
108
  "p-limit": "^3.0.1",
109
109
  "proxyquire": "^2.0.1",
110
110
  "retry-request": "^4.1.1",
111
- "sinon": "^12.0.0",
111
+ "sinon": "^13.0.0",
112
112
  "stats-lite": "^2.1.1",
113
113
  "teeny-request": "^7.0.0",
114
114
  "time-span": "^4.0.0",