@google-cloud/firestore
Advanced tools
Comparing version 3.3.3 to 3.3.4
@@ -480,2 +480,4 @@ /*! | ||
* @param backendStream The Node stream to monitor. | ||
* @param lifetime A Promise that resolves when the stream receives an 'end', | ||
* 'close' or 'finish' message. | ||
* @param requestTag A unique client-assigned identifier for this request. | ||
@@ -482,0 +484,0 @@ * @param request If specified, the request that should be written to the |
@@ -842,2 +842,4 @@ "use strict"; | ||
* @param backendStream The Node stream to monitor. | ||
* @param lifetime A Promise that resolves when the stream receives an 'end', | ||
* 'close' or 'finish' message. | ||
* @param requestTag A unique client-assigned identifier for this request. | ||
@@ -849,3 +851,3 @@ * @param request If specified, the request that should be written to the | ||
*/ | ||
_initializeStream(backendStream, requestTag, request) { | ||
_initializeStream(backendStream, lifetime, requestTag, request) { | ||
const resultStream = new stream_1.PassThrough({ objectMode: true }); | ||
@@ -866,10 +868,12 @@ resultStream.pause(); | ||
} | ||
backendStream.on('data', () => streamReady()); | ||
function streamEnded() { | ||
logger_1.logger('Firestore._initializeStream', requestTag, 'Received stream end'); | ||
streamReady(); | ||
resultStream.unpipe(backendStream); | ||
resolve(resultStream); | ||
lifetime.resolve(); | ||
} | ||
backendStream.on('data', () => streamReady()); | ||
backendStream.on('end', () => streamEnded()); | ||
backendStream.on('close', () => streamEnded()); | ||
backendStream.on('finish', () => streamEnded()); | ||
backendStream.on('error', err => { | ||
@@ -890,3 +894,3 @@ if (!streamInitialized) { | ||
resultStream.emit('error', err); | ||
}, 0); | ||
}); | ||
} | ||
@@ -947,33 +951,31 @@ }); | ||
const callOptions = this.createCallOptions(); | ||
const bidrectional = methodName === 'listen'; | ||
const result = new util_1.Deferred(); | ||
this._clientPool.run(requestTag, gapicClient => { | ||
// While we return the stream to the callee early, we don't want to | ||
// release the GAPIC client until the callee has finished processing the | ||
// stream. | ||
const lifetime = new util_1.Deferred(); | ||
this._retry(methodName, requestTag, async () => { | ||
const bidirectional = methodName === 'listen'; | ||
return this._retry(methodName, requestTag, () => { | ||
const result = new util_1.Deferred(); | ||
this._clientPool.run(requestTag, async (gapicClient) => { | ||
logger_1.logger('Firestore.requestStream', requestTag, 'Sending request: %j', request); | ||
const stream = bidrectional | ||
? gapicClient[methodName](callOptions) | ||
: gapicClient[methodName](request, callOptions); | ||
const logStream = through2.obj(function (chunk, enc, callback) { | ||
logger_1.logger('Firestore.requestStream', requestTag, 'Received response: %j', chunk); | ||
callback(); | ||
}); | ||
stream.pipe(logStream); | ||
stream.on('close', lifetime.resolve); | ||
stream.on('end', lifetime.resolve); | ||
stream.on('finish', lifetime.resolve); | ||
stream.on('error', lifetime.resolve); | ||
const resultStream = await this._initializeStream(stream, requestTag, bidrectional ? request : undefined); | ||
resultStream.on('end', () => stream.end()); | ||
result.resolve(resultStream); | ||
}).catch(err => { | ||
lifetime.resolve(); | ||
result.reject(err); | ||
try { | ||
const stream = bidirectional | ||
? gapicClient[methodName](callOptions) | ||
: gapicClient[methodName](request, callOptions); | ||
const logStream = through2.obj(function (chunk, enc, callback) { | ||
logger_1.logger('Firestore.requestStream', requestTag, 'Received response: %j', chunk); | ||
callback(); | ||
}); | ||
stream.pipe(logStream); | ||
const lifetime = new util_1.Deferred(); | ||
const resultStream = await this._initializeStream(stream, lifetime, requestTag, bidirectional ? request : undefined); | ||
resultStream.on('end', () => stream.end()); | ||
result.resolve(resultStream); | ||
// While we return the stream to the callee early, we don't want to | ||
// release the GAPIC client until the callee has finished processing the | ||
// stream. | ||
return lifetime.promise; | ||
} | ||
catch (e) { | ||
result.reject(e); | ||
} | ||
}); | ||
return lifetime.promise; | ||
return result.promise; | ||
}); | ||
return result.promise; | ||
} | ||
@@ -980,0 +982,0 @@ } |
@@ -7,2 +7,11 @@ # Changelog | ||
### [3.3.4](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.3...v3.3.4) (2020-01-12) | ||
### Bug Fixes | ||
* do not release client before retry ([#870](https://www.github.com/googleapis/nodejs-firestore/issues/870)) ([47f7ab5](https://www.github.com/googleapis/nodejs-firestore/commit/47f7ab52f9133064785754ee924d9f8736853eba)) | ||
* proper routing headers ([43472f6](https://www.github.com/googleapis/nodejs-firestore/commit/43472f6bd51a22a5ee27d7fc0f88a9dd97c22336)) | ||
* remove redundant log line ([#868](https://www.github.com/googleapis/nodejs-firestore/issues/868)) ([af3196f](https://www.github.com/googleapis/nodejs-firestore/commit/af3196fe8da2018e0a9842f4f62588ce2c740597)) | ||
### [3.3.3](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.2...v3.3.3) (2020-01-08) | ||
@@ -9,0 +18,0 @@ |
{ | ||
"name": "@google-cloud/firestore", | ||
"description": "Firestore Client Library for Node.js", | ||
"version": "3.3.3", | ||
"version": "3.3.4", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google Inc.", |
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
2418422
49392