Socket
Socket
Sign inDemoInstall

google-gax

Package Overview
Dependencies
Maintainers
4
Versions
362
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-gax - npm Package Compare versions

Comparing version 4.3.5 to 4.3.6

2

build/src/streamingCalls/streaming.d.ts

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

streamHandoffHelper(stream: CancellableStream, retry: RetryOptions): void;
eventForwardHelper(stream: Stream): void;
statusMetadataHelper(stream: Stream): void;
/**

@@ -98,0 +100,0 @@ * Forward events from an API request stream to the user's stream.

62

build/src/streamingCalls/streaming.js

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

let enteredError = false;
const eventsToForward = ['metadata', 'response', 'status'];
eventsToForward.forEach(event => {
stream.on(event, this.emit.bind(this, event));
});
this.eventForwardHelper(stream);
stream.on('error', error => {

@@ -204,10 +201,3 @@ enteredError = true;

}
/**
* Forward events from an API request stream to the user's stream.
* @param {Stream} stream - The API request stream.
* @param {RetryOptions} retry - Configures the exceptions upon which the
* function should retry, and the parameters to the exponential backoff retry
* algorithm.
*/
forwardEvents(stream) {
eventForwardHelper(stream) {
const eventsToForward = ['metadata', 'response', 'status'];

@@ -217,2 +207,4 @@ eventsToForward.forEach(event => {

});
}
statusMetadataHelper(stream) {
// gRPC is guaranteed emit the 'status' event but not 'metadata', and 'status' is the last event to emit.

@@ -247,2 +239,13 @@ // Emit the 'response' event if stream has no 'metadata' event.

});
}
/**
* Forward events from an API request stream to the user's stream.
* @param {Stream} stream - The API request stream.
* @param {RetryOptions} retry - Configures the exceptions upon which the
* function should retry, and the parameters to the exponential backoff retry
* algorithm.
*/
forwardEvents(stream) {
this.eventForwardHelper(stream);
this.statusMetadataHelper(stream);
stream.on('error', error => {

@@ -269,35 +272,4 @@ googleError_1.GoogleError.parseGRPCStatusDetails(error);

let retryStream = this.stream;
const eventsToForward = ['metadata', 'response', 'status'];
eventsToForward.forEach(event => {
stream.on(event, this.emit.bind(this, event));
});
// gRPC is guaranteed emit the 'status' event but not 'metadata', and 'status' is the last event to emit.
// Emit the 'response' event if stream has no 'metadata' event.
// This avoids the stream swallowing the other events, such as 'end'.
stream.on('status', () => {
if (!this._responseHasSent) {
stream.emit('response', {
code: 200,
details: '',
message: 'OK',
});
}
});
// We also want to supply the status data as 'response' event to support
// the behavior of google-cloud-node expects.
// see:
// https://github.com/GoogleCloudPlatform/google-cloud-node/pull/1775#issuecomment-259141029
// https://github.com/GoogleCloudPlatform/google-cloud-node/blob/116436fa789d8b0f7fc5100b19b424e3ec63e6bf/packages/common/src/grpc-service.js#L355
stream.on('metadata', metadata => {
// Create a response object with succeeds.
// TODO: unify this logic with the decoration of gRPC response when it's
// added. see: https://github.com/googleapis/gax-nodejs/issues/65
stream.emit('response', {
code: 200,
details: '',
message: 'OK',
metadata,
});
this._responseHasSent = true;
});
this.eventForwardHelper(stream);
this.statusMetadataHelper(stream);
stream.on('error', error => {

@@ -304,0 +276,0 @@ const timeout = retry.backoffSettings.totalTimeoutMillis;

interface streamingRetryRequestOptions {
request?: Function;
request: Function;
maxRetries?: number;

@@ -4,0 +4,0 @@ }

@@ -34,9 +34,3 @@ "use strict";

if (opts.request === undefined) {
try {
// eslint-disable-next-line node/no-unpublished-require
opts.request = require('request');
}
catch (e) {
throw new Error('A request library must be provided to retry-request.');
}
throw new Error('A request function must be provided');
}

@@ -43,0 +37,0 @@ let numNoResponseAttempts = 0;

{
"name": "google-gax",
"version": "4.3.5",
"version": "4.3.6",
"description": "Google API Extensions",

@@ -14,3 +14,3 @@ "main": "build/src/index.js",

"@grpc/grpc-js": "~1.10.3",
"@grpc/proto-loader": "^0.7.0",
"@grpc/proto-loader": "^0.7.13",
"@types/long": "^4.0.0",

@@ -17,0 +17,0 @@ "abort-controller": "^3.0.0",

Sorry, the diff of this file is too big to display

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