Socket
Socket
Sign inDemoInstall

@grpc/grpc-js

Package Overview
Dependencies
Maintainers
3
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grpc/grpc-js - npm Package Compare versions

Comparing version 0.6.7 to 0.6.8

7

build/src/call.d.ts

@@ -39,2 +39,9 @@ /// <reference types="node" />

export declare type ClientDuplexStream<RequestType, ResponseType> = ClientWritableStream<RequestType> & ClientReadableStream<ResponseType>;
/**
* Construct a ServiceError from a StatusObject. This function exists primarily
* as an attempt to make the error stack trace clearly communicate that the
* error is not necessarily a problem in gRPC itself.
* @param status
*/
export declare function callErrorFromStatus(status: StatusObject): ServiceError;
export declare class ClientUnaryCallImpl extends EventEmitter implements ClientUnaryCall {

@@ -41,0 +48,0 @@ private readonly call;

14

build/src/call.js

@@ -22,2 +22,13 @@ "use strict";

const constants_1 = require("./constants");
/**
* Construct a ServiceError from a StatusObject. This function exists primarily
* as an attempt to make the error stack trace clearly communicate that the
* error is not necessarily a problem in gRPC itself.
* @param status
*/
function callErrorFromStatus(status) {
const message = `${status.code} ${constants_1.Status[status.code]}: ${status.details}`;
return Object.assign(new Error(message), status);
}
exports.callErrorFromStatus = callErrorFromStatus;
class ClientUnaryCallImpl extends events_1.EventEmitter {

@@ -69,4 +80,3 @@ constructor(call) {

if (status.code !== constants_1.Status.OK) {
const error = Object.assign(new Error(status.details), status);
stream.emit('error', error);
stream.emit('error', callErrorFromStatus(status));
}

@@ -73,0 +83,0 @@ stream.emit('status', status);

3

build/src/client.js

@@ -96,4 +96,3 @@ "use strict";

else {
const error = Object.assign(new Error(status.details), status);
callback(error);
callback(call_1.callErrorFromStatus(status));
}

@@ -100,0 +99,0 @@ });

@@ -9,3 +9,3 @@ /// <reference types="node" />

import { LogVerbosity, Status } from './constants';
import { Deserialize, loadPackageDefinition, makeClientConstructor, Serialize } from './make-client';
import { Deserialize, loadPackageDefinition, makeClientConstructor, Serialize, ServiceDefinition } from './make-client';
import { Metadata } from './metadata';

@@ -15,3 +15,3 @@ import { Server, UntypedHandleCall, UntypedServiceImplementation } from './server';

import { StatusBuilder } from './status-builder';
import { ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream } from './server-call';
import { handleBidiStreamingCall, handleServerStreamingCall, handleUnaryCall, ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream } from './server-call';
export interface OAuth2Client {

@@ -41,3 +41,5 @@ getRequestMetadata: (url: string, callback: (err: Error | null, headers?: {

export declare const waitForClientReady: (client: Client, deadline: number | Date, callback: (error?: Error | undefined) => void) => void;
export { ChannelCredentials, CallCredentials, Deadline, Serialize as serialize, Deserialize as deserialize, ClientUnaryCall, ClientReadableStream, ClientWritableStream, ClientDuplexStream, CallOptions, StatusObject, ServiceError, ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream, UntypedHandleCall, UntypedServiceImplementation, };
export { ChannelCredentials, CallCredentials, Deadline, Serialize as serialize, Deserialize as deserialize, ClientUnaryCall, ClientReadableStream, ClientWritableStream, ClientDuplexStream, CallOptions, StatusObject, ServiceError, ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream, ServiceDefinition, UntypedHandleCall, UntypedServiceImplementation, };
/**** Server ****/
export { handleBidiStreamingCall, handleServerStreamingCall, handleUnaryCall, };
export declare type Call = ClientUnaryCall | ClientReadableStream<any> | ClientWritableStream<any> | ClientDuplexStream<any, any>;

@@ -44,0 +46,0 @@ export declare type MetadataListener = (metadata: Metadata, next: Function) => void;

@@ -276,4 +276,9 @@ "use strict";

// lbConfig has no useful information for pick first load balancing
this.latestAddressList = addressList;
this.connectToAddressList();
/* To avoid unnecessary churn, we only do something with this address list
* if we're not currently trying to establish a connection, or if the new
* address list is different from the existing one */
if (this.subchannels.length === 0 || !this.latestAddressList.every((value, index) => addressList[index] === value)) {
this.latestAddressList = addressList;
this.connectToAddressList();
}
}

@@ -285,3 +290,2 @@ exitIdle() {

if (this.currentState === channel_1.ConnectivityState.IDLE) {
this.channelControlHelper.requestReresolution();
if (this.latestAddressList.length > 0) {

@@ -291,2 +295,5 @@ this.connectToAddressList();

}
if (this.currentState === channel_1.ConnectivityState.IDLE || this.triedAllSubchannels) {
this.channelControlHelper.requestReresolution();
}
}

@@ -293,0 +300,0 @@ resetBackoff() {

@@ -22,3 +22,3 @@ /// <reference types="node" />

export interface ServiceDefinition {
[index: string]: MethodDefinition<object, object>;
[index: string]: MethodDefinition<any, any>;
}

@@ -25,0 +25,0 @@ export interface ProtobufTypeDefinition {

@@ -182,16 +182,31 @@ "use strict";

}
this.session = http2.connect(addressScheme + this.subchannelAddress, connectionOptions);
this.session.unref();
this.session.once('connect', () => {
this.transitionToState([channel_1.ConnectivityState.CONNECTING], channel_1.ConnectivityState.READY);
const session = http2.connect(addressScheme + this.subchannelAddress, connectionOptions);
this.session = session;
session.unref();
/* For all of these events, check if the session at the time of the event
* is the same one currently attached to this subchannel, to ensure that
* old events from previous connection attempts cannot cause invalid state
* transitions. */
session.once('connect', () => {
if (this.session === session) {
this.transitionToState([channel_1.ConnectivityState.CONNECTING], channel_1.ConnectivityState.READY);
}
});
this.session.once('close', () => {
this.transitionToState([channel_1.ConnectivityState.CONNECTING, channel_1.ConnectivityState.READY], channel_1.ConnectivityState.TRANSIENT_FAILURE);
session.once('close', () => {
if (this.session === session) {
this.transitionToState([channel_1.ConnectivityState.CONNECTING], channel_1.ConnectivityState.TRANSIENT_FAILURE);
/* Transitioning directly to IDLE here should be OK because we are not
* doing any backoff, because a connection was established at some
* point */
this.transitionToState([channel_1.ConnectivityState.READY], channel_1.ConnectivityState.IDLE);
}
});
this.session.once('goaway', () => {
this.transitionToState([channel_1.ConnectivityState.CONNECTING, channel_1.ConnectivityState.READY], channel_1.ConnectivityState.IDLE);
session.once('goaway', () => {
if (this.session === session) {
this.transitionToState([channel_1.ConnectivityState.CONNECTING, channel_1.ConnectivityState.READY], channel_1.ConnectivityState.IDLE);
}
});
this.session.once('error', error => {
session.once('error', error => {
/* Do nothing here. Any error should also trigger a close event, which is
* where we want to handle that. */
* where we want to handle that. */
});

@@ -198,0 +213,0 @@ }

{
"name": "@grpc/grpc-js",
"version": "0.6.7",
"version": "0.6.8",
"description": "gRPC Library for Node - pure JS implementation",

@@ -5,0 +5,0 @@ "homepage": "https://grpc.io/",

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