Socket
Socket
Sign inDemoInstall

@grpc/grpc-js

Package Overview
Dependencies
Maintainers
3
Versions
175
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 1.9.0 to 1.9.1

4

build/src/internal-channel.js

@@ -294,5 +294,3 @@ "use strict";

if (this.channelzEnabled) {
this.channelzTrace.addTrace('CT_INFO', connectivity_state_1.ConnectivityState[this.connectivityState] +
' -> ' +
connectivity_state_1.ConnectivityState[newState]);
this.channelzTrace.addTrace('CT_INFO', 'Connectivity state change to ' + connectivity_state_1.ConnectivityState[newState]);
}

@@ -299,0 +297,0 @@ this.connectivityState = newState;

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

process.nextTick(() => {
this.children[subchannelIndex].subchannel.startConnecting();
var _a;
(_a = this.children[subchannelIndex]) === null || _a === void 0 ? void 0 : _a.subchannel.startConnecting();
});

@@ -250,0 +251,0 @@ }

@@ -108,2 +108,9 @@ "use strict";

var _a, _b, _c;
/* If this call was cancelled (e.g. by the deadline) before
* metadata generation finished, we shouldn't do anything with
* it. */
if (this.ended) {
this.trace('Credentials metadata generation finished after call ended');
return;
}
const finalMetadata = this.metadata.clone();

@@ -110,0 +117,0 @@ finalMetadata.merge(credsMetadata);

@@ -36,2 +36,40 @@ "use strict";

}
/**
* Name match levels in order from most to least specific. This is the order in
* which searches will be performed.
*/
const NAME_MATCH_LEVEL_ORDER = [
'SERVICE_AND_METHOD',
'SERVICE',
'EMPTY',
];
function hasMatchingName(service, method, methodConfig, matchLevel) {
for (const name of methodConfig.name) {
switch (matchLevel) {
case 'EMPTY':
if (!name.service && !name.method) {
return true;
}
break;
case 'SERVICE':
if (name.service === service && !name.method) {
return true;
}
break;
case 'SERVICE_AND_METHOD':
if (name.service === service && name.method === method) {
return true;
}
}
}
return false;
}
function findMatchingConfig(service, method, methodConfigs, matchLevel) {
for (const config of methodConfigs) {
if (hasMatchingName(service, method, config, matchLevel)) {
return config;
}
}
return null;
}
function getDefaultConfigSelector(serviceConfig) {

@@ -44,13 +82,17 @@ return function defaultConfigSelector(methodName, metadata) {

if (serviceConfig && serviceConfig.methodConfig) {
for (const methodConfig of serviceConfig.methodConfig) {
for (const name of methodConfig.name) {
if (name.service === service &&
(name.method === undefined || name.method === method)) {
return {
methodConfig: methodConfig,
pickInformation: {},
status: constants_1.Status.OK,
dynamicFilterFactories: [],
};
}
/* Check for the following in order, and return the first method
* config that matches:
* 1. A name that exactly matches the service and method
* 2. A name with no method set that matches the service
* 3. An empty name
*/
for (const matchLevel of NAME_MATCH_LEVEL_ORDER) {
const matchingConfig = findMatchingConfig(service, method, serviceConfig.methodConfig, matchLevel);
if (matchingConfig) {
return {
methodConfig: matchingConfig,
pickInformation: {},
status: constants_1.Status.OK,
dynamicFilterFactories: [],
};
}

@@ -57,0 +99,0 @@ }

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

cancelled: boolean;
deadlineTimer: NodeJS.Timer | null;
deadlineTimer: NodeJS.Timeout | null;
private statusSent;

@@ -132,0 +132,0 @@ private deadline;

@@ -5,3 +5,3 @@ import { Status } from './constants';

export interface MethodConfigName {
service: string;
service?: string;
method?: string;

@@ -8,0 +8,0 @@ }

@@ -43,17 +43,28 @@ "use strict";

function validateName(obj) {
if (!('service' in obj) || typeof obj.service !== 'string') {
throw new Error('Invalid method config name: invalid service');
}
const result = {
service: obj.service,
};
if ('method' in obj) {
if (typeof obj.method === 'string') {
result.method = obj.method;
// In this context, and unset field and '' are considered the same
if ('service' in obj && obj.service !== '') {
if (typeof obj.service !== 'string') {
throw new Error(`Invalid method config name: invalid service: expected type string, got ${typeof obj.service}`);
}
if ('method' in obj && obj.method !== '') {
if (typeof obj.method !== 'string') {
throw new Error(`Invalid method config name: invalid method: expected type string, got ${typeof obj.service}`);
}
return {
service: obj.service,
method: obj.method,
};
}
else {
throw new Error('Invalid method config name: invalid method');
return {
service: obj.service,
};
}
}
return result;
else {
if ('method' in obj && obj.method !== undefined) {
throw new Error(`Invalid method config name: method set with empty or unset service`);
}
return {};
}
}

@@ -60,0 +71,0 @@ function validateRetryPolicy(obj) {

@@ -425,11 +425,17 @@ "use strict";

const cb = (error) => {
var _a;
let code = constants_1.Status.UNAVAILABLE;
if ((error === null || error === void 0 ? void 0 : error.code) === 'ERR_STREAM_WRITE_AFTER_END') {
code = constants_1.Status.INTERNAL;
}
if (error) {
this.cancelWithStatus(code, `Write error: ${error.message}`);
}
(_a = context.callback) === null || _a === void 0 ? void 0 : _a.call(context);
/* nextTick here ensures that no stream action can be taken in the call
* stack of the write callback, in order to hopefully work around
* https://github.com/nodejs/node/issues/49147 */
process.nextTick(() => {
var _a;
let code = constants_1.Status.UNAVAILABLE;
if ((error === null || error === void 0 ? void 0 : error.code) ===
'ERR_STREAM_WRITE_AFTER_END') {
code = constants_1.Status.INTERNAL;
}
if (error) {
this.cancelWithStatus(code, `Write error: ${error.message}`);
}
(_a = context.callback) === null || _a === void 0 ? void 0 : _a.call(context);
});
};

@@ -436,0 +442,0 @@ this.trace('sending data chunk of length ' + message.length);

@@ -185,5 +185,3 @@ "use strict";

if (this.channelzEnabled) {
this.channelzTrace.addTrace('CT_INFO', connectivity_state_1.ConnectivityState[this.connectivityState] +
' -> ' +
connectivity_state_1.ConnectivityState[newState]);
this.channelzTrace.addTrace('CT_INFO', 'Connectivity state change to ' + connectivity_state_1.ConnectivityState[newState]);
}

@@ -190,0 +188,0 @@ const previousState = this.connectivityState;

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

@@ -68,3 +68,3 @@ "homepage": "https://grpc.io/",

"dependencies": {
"@grpc/proto-loader": "^0.7.0",
"@grpc/proto-loader": "^0.7.8",
"@types/node": ">=12.12.47"

@@ -71,0 +71,0 @@ },

@@ -66,3 +66,3 @@ /*

*/
private timerId: NodeJS.Timer;
private timerId: NodeJS.Timeout;
/**

@@ -69,0 +69,0 @@ * Indicates whether the timer is currently running.

@@ -169,3 +169,3 @@ /*

*/
private readonly callRefTimer: NodeJS.Timer;
private readonly callRefTimer: NodeJS.Timeout;
private configSelector: ConfigSelector | null = null;

@@ -186,3 +186,3 @@ /**

private callCount = 0;
private idleTimer: NodeJS.Timer | null = null;
private idleTimer: NodeJS.Timeout | null = null;
private readonly idleTimeoutMs: number;

@@ -482,5 +482,3 @@

'CT_INFO',
ConnectivityState[this.connectivityState] +
' -> ' +
ConnectivityState[newState]
'Connectivity state change to ' + ConnectivityState[newState]
);

@@ -487,0 +485,0 @@ }

@@ -505,3 +505,3 @@ /*

private latestConfig: OutlierDetectionLoadBalancingConfig | null = null;
private ejectionTimer: NodeJS.Timer;
private ejectionTimer: NodeJS.Timeout;
private timerStartTime: Date | null = null;

@@ -508,0 +508,0 @@

@@ -309,3 +309,3 @@ /*

process.nextTick(() => {
this.children[subchannelIndex].subchannel.startConnecting();
this.children[subchannelIndex]?.subchannel.startConnecting();
});

@@ -312,0 +312,0 @@ }

@@ -143,2 +143,9 @@ /*

credsMetadata => {
/* If this call was cancelled (e.g. by the deadline) before
* metadata generation finished, we shouldn't do anything with
* it. */
if (this.ended) {
this.trace('Credentials metadata generation finished after call ended');
return;
}
const finalMetadata = this.metadata!.clone();

@@ -145,0 +152,0 @@ finalMetadata.merge(credsMetadata);

@@ -99,3 +99,3 @@ /*

private continueResolving = false;
private nextResolutionTimer: NodeJS.Timer;
private nextResolutionTimer: NodeJS.Timeout;
private isNextResolutionTimerRunning = false;

@@ -102,0 +102,0 @@ private isServiceConfigEnabled = true;

@@ -56,3 +56,3 @@ /*

private statusWatchers: ((status: StatusObject) => void)[] = [];
private deadlineTimer: NodeJS.Timer = setTimeout(() => {}, 0);
private deadlineTimer: NodeJS.Timeout = setTimeout(() => {}, 0);
private filterStack: FilterStack | null = null;

@@ -59,0 +59,0 @@

@@ -24,3 +24,7 @@ /*

} from './load-balancer';
import { ServiceConfig, validateServiceConfig } from './service-config';
import {
MethodConfig,
ServiceConfig,
validateServiceConfig,
} from './service-config';
import { ConnectivityState } from './connectivity-state';

@@ -47,2 +51,55 @@ import { ConfigSelector, createResolver, Resolver } from './resolver';

type NameMatchLevel = 'EMPTY' | 'SERVICE' | 'SERVICE_AND_METHOD';
/**
* Name match levels in order from most to least specific. This is the order in
* which searches will be performed.
*/
const NAME_MATCH_LEVEL_ORDER: NameMatchLevel[] = [
'SERVICE_AND_METHOD',
'SERVICE',
'EMPTY',
];
function hasMatchingName(
service: string,
method: string,
methodConfig: MethodConfig,
matchLevel: NameMatchLevel
): boolean {
for (const name of methodConfig.name) {
switch (matchLevel) {
case 'EMPTY':
if (!name.service && !name.method) {
return true;
}
break;
case 'SERVICE':
if (name.service === service && !name.method) {
return true;
}
break;
case 'SERVICE_AND_METHOD':
if (name.service === service && name.method === method) {
return true;
}
}
}
return false;
}
function findMatchingConfig(
service: string,
method: string,
methodConfigs: MethodConfig[],
matchLevel: NameMatchLevel
): MethodConfig | null {
for (const config of methodConfigs) {
if (hasMatchingName(service, method, config, matchLevel)) {
return config;
}
}
return null;
}
function getDefaultConfigSelector(

@@ -59,15 +116,22 @@ serviceConfig: ServiceConfig | null

if (serviceConfig && serviceConfig.methodConfig) {
for (const methodConfig of serviceConfig.methodConfig) {
for (const name of methodConfig.name) {
if (
name.service === service &&
(name.method === undefined || name.method === method)
) {
return {
methodConfig: methodConfig,
pickInformation: {},
status: Status.OK,
dynamicFilterFactories: [],
};
}
/* Check for the following in order, and return the first method
* config that matches:
* 1. A name that exactly matches the service and method
* 2. A name with no method set that matches the service
* 3. An empty name
*/
for (const matchLevel of NAME_MATCH_LEVEL_ORDER) {
const matchingConfig = findMatchingConfig(
service,
method,
serviceConfig.methodConfig,
matchLevel
);
if (matchingConfig) {
return {
methodConfig: matchingConfig,
pickInformation: {},
status: Status.OK,
dynamicFilterFactories: [],
};
}

@@ -74,0 +138,0 @@ }

@@ -197,3 +197,3 @@ /*

private attempts = 0;
private hedgingTimer: NodeJS.Timer | null = null;
private hedgingTimer: NodeJS.Timeout | null = null;
private committedCallIndex: number | null = null;

@@ -200,0 +200,0 @@ private initialRetryBackoffSec = 0;

@@ -411,3 +411,3 @@ /*

cancelled = false;
deadlineTimer: NodeJS.Timer | null = null;
deadlineTimer: NodeJS.Timeout | null = null;
private statusSent = false;

@@ -414,0 +414,0 @@ private deadline: Deadline = Infinity;

@@ -1082,4 +1082,4 @@ /*

}
let connectionAgeTimer: NodeJS.Timer | null = null;
let connectionAgeGraceTimer: NodeJS.Timer | null = null;
let connectionAgeTimer: NodeJS.Timeout | null = null;
let connectionAgeGraceTimer: NodeJS.Timeout | null = null;
let sessionClosedByServer = false;

@@ -1119,3 +1119,3 @@ if (this.maxConnectionAgeMs !== UNLIMITED_CONNECTION_AGE_MS) {

}
const keeapliveTimeTimer: NodeJS.Timer | null = setInterval(() => {
const keeapliveTimeTimer: NodeJS.Timeout | null = setInterval(() => {
const timeoutTImer = setTimeout(() => {

@@ -1122,0 +1122,0 @@ sessionClosedByServer = true;

@@ -38,3 +38,3 @@ /*

export interface MethodConfigName {
service: string;
service?: string;
method?: string;

@@ -99,16 +99,32 @@ }

function validateName(obj: any): MethodConfigName {
if (!('service' in obj) || typeof obj.service !== 'string') {
throw new Error('Invalid method config name: invalid service');
}
const result: MethodConfigName = {
service: obj.service,
};
if ('method' in obj) {
if (typeof obj.method === 'string') {
result.method = obj.method;
// In this context, and unset field and '' are considered the same
if ('service' in obj && obj.service !== '') {
if (typeof obj.service !== 'string') {
throw new Error(
`Invalid method config name: invalid service: expected type string, got ${typeof obj.service}`
);
}
if ('method' in obj && obj.method !== '') {
if (typeof obj.method !== 'string') {
throw new Error(
`Invalid method config name: invalid method: expected type string, got ${typeof obj.service}`
);
}
return {
service: obj.service,
method: obj.method,
};
} else {
throw new Error('Invalid method config name: invalid method');
return {
service: obj.service,
};
}
} else {
if ('method' in obj && obj.method !== undefined) {
throw new Error(
`Invalid method config name: method set with empty or unset service`
);
}
return {};
}
return result;
}

@@ -115,0 +131,0 @@

@@ -504,12 +504,18 @@ /*

const cb: WriteCallback = (error?: Error | null) => {
let code: Status = Status.UNAVAILABLE;
if (
(error as NodeJS.ErrnoException)?.code === 'ERR_STREAM_WRITE_AFTER_END'
) {
code = Status.INTERNAL;
}
if (error) {
this.cancelWithStatus(code, `Write error: ${error.message}`);
}
context.callback?.();
/* nextTick here ensures that no stream action can be taken in the call
* stack of the write callback, in order to hopefully work around
* https://github.com/nodejs/node/issues/49147 */
process.nextTick(() => {
let code: Status = Status.UNAVAILABLE;
if (
(error as NodeJS.ErrnoException)?.code ===
'ERR_STREAM_WRITE_AFTER_END'
) {
code = Status.INTERNAL;
}
if (error) {
this.cancelWithStatus(code, `Write error: ${error.message}`);
}
context.callback?.();
});
};

@@ -516,0 +522,0 @@ this.trace('sending data chunk of length ' + message.length);

@@ -48,3 +48,3 @@ /*

*/
private cleanupTimer: NodeJS.Timer | null = null;
private cleanupTimer: NodeJS.Timeout | null = null;

@@ -51,0 +51,0 @@ /**

@@ -280,5 +280,3 @@ /*

'CT_INFO',
ConnectivityState[this.connectivityState] +
' -> ' +
ConnectivityState[newState]
'Connectivity state change to ' + ConnectivityState[newState]
);

@@ -285,0 +283,0 @@ }

@@ -111,3 +111,3 @@ /*

*/
private keepaliveTimerId: NodeJS.Timer | null = null;
private keepaliveTimerId: NodeJS.Timeout | null = null;
/**

@@ -121,3 +121,3 @@ * Indicates that the keepalive timer ran out while there were no active

*/
private keepaliveTimeoutId: NodeJS.Timer | null = null;
private keepaliveTimeoutId: NodeJS.Timeout | null = null;
/**

@@ -124,0 +124,0 @@ * Indicates whether keepalive pings should be sent without any active calls

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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