@google-cloud/firestore
Advanced tools
Comparing version 4.7.2 to 4.8.0
@@ -6,7 +6,5 @@ /// <reference types="node" /> | ||
* Builds a Firestore data bundle with results from the given document and query snapshots. | ||
* | ||
* @private | ||
*/ | ||
export declare class BundleBuilder { | ||
private bundleId; | ||
readonly bundleId: string; | ||
private documents; | ||
@@ -13,0 +11,0 @@ private namedQueries; |
@@ -23,4 +23,2 @@ "use strict"; | ||
* Builds a Firestore data bundle with results from the given document and query snapshots. | ||
* | ||
* @private | ||
*/ | ||
@@ -27,0 +25,0 @@ class BundleBuilder { |
@@ -468,6 +468,4 @@ /*! | ||
* If not specified, a random identifier will be used. | ||
* | ||
* @private | ||
*/ | ||
_bundle(name?: string): BundleBuilder; | ||
bundle(name?: string): BundleBuilder; | ||
/** | ||
@@ -474,0 +472,0 @@ * Executes the given updateFunction and commits the changes applied within |
@@ -679,6 +679,4 @@ "use strict"; | ||
* If not specified, a random identifier will be used. | ||
* | ||
* @private | ||
*/ | ||
_bundle(name) { | ||
bundle(name) { | ||
return new bundle_1.BundleBuilder(name || util_1.autoId()); | ||
@@ -685,0 +683,0 @@ } |
@@ -34,6 +34,11 @@ /*! | ||
* Stores each active clients and how many operations it has outstanding. | ||
* @private | ||
*/ | ||
private activeClients; | ||
/** | ||
* A set of clients that have seen RST_STREAM errors (see | ||
* https://github.com/googleapis/nodejs-firestore/issues/1023) and should | ||
* no longer be used. | ||
*/ | ||
private failedClients; | ||
/** | ||
* Whether the Firestore instance has been terminated. Once terminated, the | ||
@@ -40,0 +45,0 @@ * ClientPool can longer schedule new operations. |
@@ -50,6 +50,11 @@ "use strict"; | ||
* Stores each active clients and how many operations it has outstanding. | ||
* @private | ||
*/ | ||
this.activeClients = new Map(); | ||
/** | ||
* A set of clients that have seen RST_STREAM errors (see | ||
* https://github.com/googleapis/nodejs-firestore/issues/1023) and should | ||
* no longer be used. | ||
*/ | ||
this.failedClients = new Set(); | ||
/** | ||
* Whether the Firestore instance has been terminated. Once terminated, the | ||
@@ -78,3 +83,4 @@ * ClientPool can longer schedule new operations. | ||
// complete. | ||
if (requestCount > selectedClientRequestCount && | ||
if (!this.failedClients.has(client) && | ||
requestCount > selectedClientRequestCount && | ||
requestCount < this.concurrentOperationLimit) { | ||
@@ -111,2 +117,3 @@ selectedClient = client; | ||
this.activeClients.delete(client); | ||
this.failedClients.delete(client); | ||
await this.clientDestructor(client); | ||
@@ -122,5 +129,13 @@ logger_1.logger('ClientPool.release', requestTag, 'Garbage collected 1 client'); | ||
shouldGarbageCollectClient(client) { | ||
// Don't garbage collect clients that have active requests. | ||
if (this.activeClients.get(client) !== 0) { | ||
return false; | ||
} | ||
// Idle clients that have received RST_STREAM errors are always garbage | ||
// collected. | ||
if (this.failedClients.has(client)) { | ||
return true; | ||
} | ||
// Otherwise, only garbage collect if we have too much idle capacity (e.g. | ||
// more than 100 idle capacity with default settings) . | ||
let idleCapacityCount = 0; | ||
@@ -172,3 +187,10 @@ for (const [, count] of this.activeClients) { | ||
.catch(async (err) => { | ||
var _a; | ||
await this.release(requestTag, client); | ||
if ((_a = err.message) === null || _a === void 0 ? void 0 : _a.indexOf('RST_STREAM')) { | ||
// Once a client has seen a RST_STREAM error, the GRPC channel can | ||
// no longer be used. We mark the client as failed, which ensures that | ||
// we open a new GRPC channel for the next request. | ||
this.failedClients.add(client); | ||
} | ||
return Promise.reject(err); | ||
@@ -175,0 +197,0 @@ }) |
@@ -7,2 +7,14 @@ # Changelog | ||
## [4.8.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.7.2...v4.8.0) (2020-12-03) | ||
### Features | ||
* Add support to build Firestore bundles ([#1365](https://www.github.com/googleapis/nodejs-firestore/issues/1365)) ([bae82dd](https://www.github.com/googleapis/nodejs-firestore/commit/bae82dd4438ac03107c221c62dbce8cf6d20a4b1)) | ||
### Bug Fixes | ||
* stop using GRPC channels after RST_STREAM ([#1373](https://www.github.com/googleapis/nodejs-firestore/issues/1373)) ([504bb5f](https://www.github.com/googleapis/nodejs-firestore/commit/504bb5f34159238cd9bed3645591e6c6c810452b)) | ||
### [4.7.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.7.1...v4.7.2) (2020-11-25) | ||
@@ -9,0 +21,0 @@ |
{ | ||
"name": "@google-cloud/firestore", | ||
"description": "Firestore Client Library for Node.js", | ||
"version": "4.7.2", | ||
"version": "4.8.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google Inc.", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4507461
83887