Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/firestore

Package Overview
Dependencies
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/firestore - npm Package Compare versions

Comparing version 3.8.5 to 3.8.6

3

build/src/backoff.d.ts

@@ -16,2 +16,3 @@ /*!

*/
/// <reference types="node" />
/*!

@@ -25,3 +26,3 @@ * The maximum number of retries that will be attempted by backoff

*/
export declare let delayExecution: (f: () => void, ms: number) => void;
export declare let delayExecution: (f: () => void, ms: number) => NodeJS.Timeout;
/**

@@ -28,0 +29,0 @@ * Allows overriding of the timeout handler used by the exponential backoff

@@ -65,3 +65,20 @@ "use strict";

function setTimeoutHandler(handler) {
exports.delayExecution = handler;
exports.delayExecution = (f, ms) => {
handler(f, ms);
const timeout = {
hasRef: () => {
throw new Error('For tests only. Not Implemented');
},
ref: () => {
throw new Error('For tests only. Not Implemented');
},
refresh: () => {
throw new Error('For tests only. Not Implemented');
},
unref: () => {
throw new Error('For tests only. Not Implemented');
},
};
return timeout;
};
}

@@ -68,0 +85,0 @@ exports.setTimeoutHandler = setTimeoutHandler;

@@ -162,3 +162,3 @@ "use strict";

if (this.terminated) {
return Promise.reject('The client has already been terminated');
return Promise.reject(new Error('The client has already been terminated'));
}

@@ -165,0 +165,0 @@ const client = this.acquire(requestTag);

@@ -96,2 +96,2 @@ /*!

*/
export declare function wrapError(err: Error | string, stack: string): Error;
export declare function wrapError(err: Error, stack: string): Error;

@@ -155,7 +155,2 @@ "use strict";

function wrapError(err, stack) {
// TODO(b/157506412): Remove `string` type and clean up any string errors
// that we are throwing.
if (typeof err === 'string') {
throw err;
}
err.stack += '\nCaused by: ' + stack;

@@ -162,0 +157,0 @@ return err;

@@ -200,3 +200,3 @@ "use strict";

if (this._terminated) {
return Promise.reject('The client has already been closed.');
return Promise.reject(new Error('The client has already been closed.'));
}

@@ -203,0 +203,0 @@ const func = stub[methodName];

@@ -183,3 +183,3 @@ "use strict";

if (this._terminated) {
return Promise.reject('The client has already been closed.');
return Promise.reject(new Error('The client has already been closed.'));
}

@@ -186,0 +186,0 @@ const func = stub[methodName];

@@ -191,3 +191,3 @@ "use strict";

if (this._terminated) {
return Promise.reject('The client has already been closed.');
return Promise.reject(new Error('The client has already been closed.'));
}

@@ -194,0 +194,0 @@ const func = stub[methodName];

@@ -24,2 +24,10 @@ /*!

/**
* Idle timeout used to detect Watch streams that stall (see
* https://github.com/googleapis/nodejs-firestore/issues/1057, b/156308554).
* Under normal load, the Watch backend will send a TARGET_CHANGE message
* roughly every 30 seconds. As discussed with the backend team, we reset the
* Watch stream if we do not receive any message within 120 seconds.
*/
export declare const WATCH_IDLE_TIMEOUT_MS: number;
/**
* @private

@@ -106,2 +114,7 @@ * @callback docsCallback

private hasPushed;
/**
* The handler used to restart the Watch stream if it has been idle for more
* than WATCH_IDLE_TIMEOUT_MS.
*/
private idleTimeoutHandle?;
private onNext;

@@ -164,2 +177,8 @@ private onError;

/**
* Cancels the current idle timeout and reschedules a new timer.
*
* @private
*/
private resetIdleTimeout;
/**
* Helper to restart the outgoing stream to the backend.

@@ -236,2 +255,4 @@ * @private

private isResourceExhaustedError;
/** Closes the stream and clears all timeouts. */
private shutdown;
}

@@ -238,0 +259,0 @@ /**

@@ -35,2 +35,10 @@ "use strict";

const WATCH_TARGET_ID = 0x1;
/**
* Idle timeout used to detect Watch streams that stall (see
* https://github.com/googleapis/nodejs-firestore/issues/1057, b/156308554).
* Under normal load, the Watch backend will send a TARGET_CHANGE message
* roughly every 30 seconds. As discussed with the backend team, we reset the
* Watch stream if we do not receive any message within 120 seconds.
*/
exports.WATCH_IDLE_TIMEOUT_MS = 120 * 1000;
/*!

@@ -143,12 +151,5 @@ * Sentinel value for a document remove.

// Prevent further callbacks.
if (this.isActive) {
// Unregister the listener iff it has not already been unregistered.
this.firestore.unregisterListener();
this.isActive = false;
}
this.onNext = () => { };
this.onError = () => { };
if (this.currentStream) {
this.currentStream.end();
}
this.shutdown();
};

@@ -212,12 +213,7 @@ this.firestore.registerListener();

closeStream(err) {
if (this.currentStream) {
this.currentStream.end();
this.currentStream = null;
}
if (this.isActive) {
this.firestore.unregisterListener();
this.isActive = false;
logger_1.logger('Watch.closeStream', this.requestTag, 'Invoking onError: ', err);
this.onError(err);
}
this.shutdown();
}

@@ -231,3 +227,3 @@ /**

if (this.isActive && !this.isPermanentWatchError(err)) {
logger_1.logger('Watch.maybeReopenStream', this.requestTag, 'Stream ended, re-opening after retryable error: ', err);
logger_1.logger('Watch.maybeReopenStream', this.requestTag, 'Stream ended, re-opening after retryable error:', err);
this.changeMap.clear();

@@ -244,2 +240,21 @@ if (this.isResourceExhaustedError(err)) {

/**
* Cancels the current idle timeout and reschedules a new timer.
*
* @private
*/
resetIdleTimeout() {
if (this.idleTimeoutHandle) {
clearTimeout(this.idleTimeoutHandle);
}
this.idleTimeoutHandle = backoff_1.delayExecution(() => {
var _a;
logger_1.logger('Watch.resetIdleTimeout', this.requestTag, 'Resetting stream after idle timeout');
(_a = this.currentStream) === null || _a === void 0 ? void 0 : _a.end();
this.currentStream = null;
const error = new google_gax_1.GoogleError('Watch stream idle timeout');
error.code = google_gax_1.Status.UNKNOWN;
this.maybeReopenStream(error);
}, exports.WATCH_IDLE_TIMEOUT_MS);
}
/**
* Helper to restart the outgoing stream to the backend.

@@ -284,3 +299,5 @@ * @private

this.currentStream = backendStream;
this.resetIdleTimeout();
this.currentStream.on('data', (proto) => {
this.resetIdleTimeout();
this.onData(proto);

@@ -563,2 +580,16 @@ })

}
/** Closes the stream and clears all timeouts. */
shutdown() {
var _a;
if (this.isActive) {
this.isActive = false;
if (this.idleTimeoutHandle) {
clearTimeout(this.idleTimeoutHandle);
this.idleTimeoutHandle = undefined;
}
this.firestore.unregisterListener();
}
(_a = this.currentStream) === null || _a === void 0 ? void 0 : _a.end();
this.currentStream = null;
}
}

@@ -565,0 +596,0 @@ /**

@@ -7,2 +7,10 @@ # Changelog

### [3.8.6](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.5...v3.8.6) (2020-06-19)
### Bug Fixes
* reject all promises with errors ([#1224](https://www.github.com/googleapis/nodejs-firestore/issues/1224)) ([9118521](https://www.github.com/googleapis/nodejs-firestore/commit/9118521a0382fd2d484803a89e590c1bf6d2a3c6))
* restart onSnapshot() listeners that stop receiving updates ([#1220](https://www.github.com/googleapis/nodejs-firestore/issues/1220)) ([49ca641](https://www.github.com/googleapis/nodejs-firestore/commit/49ca641ca5d813923b3d4efd113bfc5aecd32437))
### [3.8.5](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.4...v3.8.5) (2020-06-10)

@@ -9,0 +17,0 @@

{
"name": "@google-cloud/firestore",
"description": "Firestore Client Library for Node.js",
"version": "3.8.5",
"version": "3.8.6",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "author": "Google Inc.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc