Skip to content

Commit 220a702

Browse files
committed
Merge remote-tracking branch 'upstream/@grpc/[email protected]' into v1.18.x_upmerge
2 parents 9ce6e49 + 3e13d84 commit 220a702

29 files changed

+159
-190
lines changed

packages/grpc-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grpc/grpc-js",
3-
"version": "1.8.14",
3+
"version": "1.8.18",
44
"description": "gRPC Library for Node - pure JS implementation",
55
"homepage": "https://grpc.io/",
66
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

packages/grpc-js/src/channel-credentials.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ export type CheckServerIdentityCallback = (
4343
cert: PeerCertificate
4444
) => Error | undefined;
4545

46-
function bufferOrNullEqual(buf1: Buffer | null, buf2: Buffer | null) {
47-
if (buf1 === null && buf2 === null) {
48-
return true;
49-
} else {
50-
return buf1 !== null && buf2 !== null && buf1.equals(buf2);
51-
}
52-
}
53-
5446
/**
5547
* Additional peer verification options that can be set when creating
5648
* SSL credentials.
@@ -199,7 +191,7 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
199191
) {
200192
super();
201193
this.connectionOptions = {
202-
secureContext,
194+
secureContext
203195
};
204196
// Node asserts that this option is a function, so we cannot pass undefined
205197
if (verifyOptions?.checkServerIdentity) {
@@ -228,9 +220,8 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
228220
if (other instanceof SecureChannelCredentialsImpl) {
229221
return (
230222
this.secureContext === other.secureContext &&
231-
this.verifyOptions.checkServerIdentity ===
232-
other.verifyOptions.checkServerIdentity
233-
);
223+
this.verifyOptions.checkServerIdentity === other.verifyOptions.checkServerIdentity
224+
);
234225
} else {
235226
return false;
236227
}

packages/grpc-js/src/client-interceptors.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
import { Status } from './constants';
3333
import { Channel } from './channel';
3434
import { CallOptions } from './client';
35-
import { CallCredentials } from './call-credentials';
3635
import { ClientMethodDefinition } from './make-client';
3736
import { getErrorMessage } from './error';
3837

packages/grpc-js/src/client.ts

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export class Client {
322322
emitter.call = call;
323323
let responseMessage: ResponseType | null = null;
324324
let receivedStatus = false;
325-
const callerStackError = new Error();
325+
let callerStackError: Error | null = new Error();
326326
call.start(callProperties.metadata, {
327327
onReceiveMetadata: metadata => {
328328
emitter.emit('metadata', metadata);
@@ -341,24 +341,22 @@ export class Client {
341341
receivedStatus = true;
342342
if (status.code === Status.OK) {
343343
if (responseMessage === null) {
344-
const callerStack = getErrorStackString(callerStackError);
345-
callProperties.callback!(
346-
callErrorFromStatus(
347-
{
348-
code: Status.INTERNAL,
349-
details: 'No message received',
350-
metadata: status.metadata,
351-
},
352-
callerStack
353-
)
354-
);
344+
const callerStack = getErrorStackString(callerStackError!);
345+
callProperties.callback!(callErrorFromStatus({
346+
code: Status.INTERNAL,
347+
details: 'No message received',
348+
metadata: status.metadata
349+
}, callerStack));
355350
} else {
356351
callProperties.callback!(null, responseMessage);
357352
}
358353
} else {
359-
const callerStack = getErrorStackString(callerStackError);
354+
const callerStack = getErrorStackString(callerStackError!);
360355
callProperties.callback!(callErrorFromStatus(status, callerStack));
361356
}
357+
/* Avoid retaining the callerStackError object in the call context of
358+
* the status event handler. */
359+
callerStackError = null;
362360
emitter.emit('status', status);
363361
},
364362
});
@@ -452,7 +450,7 @@ export class Client {
452450
emitter.call = call;
453451
let responseMessage: ResponseType | null = null;
454452
let receivedStatus = false;
455-
const callerStackError = new Error();
453+
let callerStackError: Error | null = new Error();
456454
call.start(callProperties.metadata, {
457455
onReceiveMetadata: metadata => {
458456
emitter.emit('metadata', metadata);
@@ -471,24 +469,22 @@ export class Client {
471469
receivedStatus = true;
472470
if (status.code === Status.OK) {
473471
if (responseMessage === null) {
474-
const callerStack = getErrorStackString(callerStackError);
475-
callProperties.callback!(
476-
callErrorFromStatus(
477-
{
478-
code: Status.INTERNAL,
479-
details: 'No message received',
480-
metadata: status.metadata,
481-
},
482-
callerStack
483-
)
484-
);
472+
const callerStack = getErrorStackString(callerStackError!);
473+
callProperties.callback!(callErrorFromStatus({
474+
code: Status.INTERNAL,
475+
details: 'No message received',
476+
metadata: status.metadata
477+
}, callerStack));
485478
} else {
486479
callProperties.callback!(null, responseMessage);
487480
}
488481
} else {
489-
const callerStack = getErrorStackString(callerStackError);
482+
const callerStack = getErrorStackString(callerStackError!);
490483
callProperties.callback!(callErrorFromStatus(status, callerStack));
491484
}
485+
/* Avoid retaining the callerStackError object in the call context of
486+
* the status event handler. */
487+
callerStackError = null;
492488
emitter.emit('status', status);
493489
},
494490
});
@@ -585,7 +581,7 @@ export class Client {
585581
* call after that. */
586582
stream.call = call;
587583
let receivedStatus = false;
588-
const callerStackError = new Error();
584+
let callerStackError: Error | null = new Error();
589585
call.start(callProperties.metadata, {
590586
onReceiveMetadata(metadata: Metadata) {
591587
stream.emit('metadata', metadata);
@@ -601,9 +597,12 @@ export class Client {
601597
receivedStatus = true;
602598
stream.push(null);
603599
if (status.code !== Status.OK) {
604-
const callerStack = getErrorStackString(callerStackError);
600+
const callerStack = getErrorStackString(callerStackError!);
605601
stream.emit('error', callErrorFromStatus(status, callerStack));
606602
}
603+
/* Avoid retaining the callerStackError object in the call context of
604+
* the status event handler. */
605+
callerStackError = null;
607606
stream.emit('status', status);
608607
},
609608
});
@@ -677,7 +676,7 @@ export class Client {
677676
* call after that. */
678677
stream.call = call;
679678
let receivedStatus = false;
680-
const callerStackError = new Error();
679+
let callerStackError: Error | null = new Error();
681680
call.start(callProperties.metadata, {
682681
onReceiveMetadata(metadata: Metadata) {
683682
stream.emit('metadata', metadata);
@@ -692,9 +691,12 @@ export class Client {
692691
receivedStatus = true;
693692
stream.push(null);
694693
if (status.code !== Status.OK) {
695-
const callerStack = getErrorStackString(callerStackError);
694+
const callerStack = getErrorStackString(callerStackError!);
696695
stream.emit('error', callErrorFromStatus(status, callerStack));
697696
}
697+
/* Avoid retaining the callerStackError object in the call context of
698+
* the status event handler. */
699+
callerStackError = null;
698700
stream.emit('status', status);
699701
},
700702
});

packages/grpc-js/src/compression-filter.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,9 @@ export class CompressionFilter extends BaseFilter implements Filter {
305305
}
306306

307307
export class CompressionFilterFactory
308-
implements FilterFactory<CompressionFilter>
309-
{
310-
private sharedFilterConfig: SharedCompressionFilterConfig = {};
311-
constructor(
312-
private readonly channel: Channel,
313-
private readonly options: ChannelOptions
314-
) {}
308+
implements FilterFactory<CompressionFilter> {
309+
private sharedFilterConfig: SharedCompressionFilterConfig = {};
310+
constructor(channel: Channel, private readonly options: ChannelOptions) {}
315311
createFilter(): CompressionFilter {
316312
return new CompressionFilter(this.options, this.sharedFilterConfig);
317313
}

packages/grpc-js/src/generated/grpc/channelz/v1/ChannelConnectivityState.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,43 @@
33

44
// Original file: proto/channelz.proto
55

6-
export enum _grpc_channelz_v1_ChannelConnectivityState_State {
7-
UNKNOWN = 0,
8-
IDLE = 1,
9-
CONNECTING = 2,
10-
READY = 3,
11-
TRANSIENT_FAILURE = 4,
12-
SHUTDOWN = 5,
13-
}
6+
export const _grpc_channelz_v1_ChannelConnectivityState_State = {
7+
UNKNOWN: 'UNKNOWN',
8+
IDLE: 'IDLE',
9+
CONNECTING: 'CONNECTING',
10+
READY: 'READY',
11+
TRANSIENT_FAILURE: 'TRANSIENT_FAILURE',
12+
SHUTDOWN: 'SHUTDOWN',
13+
} as const;
14+
15+
export type _grpc_channelz_v1_ChannelConnectivityState_State =
16+
| 'UNKNOWN'
17+
| 0
18+
| 'IDLE'
19+
| 1
20+
| 'CONNECTING'
21+
| 2
22+
| 'READY'
23+
| 3
24+
| 'TRANSIENT_FAILURE'
25+
| 4
26+
| 'SHUTDOWN'
27+
| 5
28+
29+
export type _grpc_channelz_v1_ChannelConnectivityState_State__Output = typeof _grpc_channelz_v1_ChannelConnectivityState_State[keyof typeof _grpc_channelz_v1_ChannelConnectivityState_State]
1430

1531
/**
1632
* These come from the specified states in this document:
1733
* https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md
1834
*/
1935
export interface ChannelConnectivityState {
20-
'state'?: (_grpc_channelz_v1_ChannelConnectivityState_State | keyof typeof _grpc_channelz_v1_ChannelConnectivityState_State);
36+
'state'?: (_grpc_channelz_v1_ChannelConnectivityState_State);
2137
}
2238

2339
/**
2440
* These come from the specified states in this document:
2541
* https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md
2642
*/
2743
export interface ChannelConnectivityState__Output {
28-
'state': (keyof typeof _grpc_channelz_v1_ChannelConnectivityState_State);
44+
'state': (_grpc_channelz_v1_ChannelConnectivityState_State__Output);
2945
}

packages/grpc-js/src/generated/grpc/channelz/v1/ChannelTraceEvent.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,30 @@ import type { SubchannelRef as _grpc_channelz_v1_SubchannelRef, SubchannelRef__O
99
/**
1010
* The supported severity levels of trace events.
1111
*/
12-
export enum _grpc_channelz_v1_ChannelTraceEvent_Severity {
13-
CT_UNKNOWN = 0,
14-
CT_INFO = 1,
15-
CT_WARNING = 2,
16-
CT_ERROR = 3,
17-
}
12+
export const _grpc_channelz_v1_ChannelTraceEvent_Severity = {
13+
CT_UNKNOWN: 'CT_UNKNOWN',
14+
CT_INFO: 'CT_INFO',
15+
CT_WARNING: 'CT_WARNING',
16+
CT_ERROR: 'CT_ERROR',
17+
} as const;
18+
19+
/**
20+
* The supported severity levels of trace events.
21+
*/
22+
export type _grpc_channelz_v1_ChannelTraceEvent_Severity =
23+
| 'CT_UNKNOWN'
24+
| 0
25+
| 'CT_INFO'
26+
| 1
27+
| 'CT_WARNING'
28+
| 2
29+
| 'CT_ERROR'
30+
| 3
31+
32+
/**
33+
* The supported severity levels of trace events.
34+
*/
35+
export type _grpc_channelz_v1_ChannelTraceEvent_Severity__Output = typeof _grpc_channelz_v1_ChannelTraceEvent_Severity[keyof typeof _grpc_channelz_v1_ChannelTraceEvent_Severity]
1836

1937
/**
2038
* A trace event is an interesting thing that happened to a channel or
@@ -28,7 +46,7 @@ export interface ChannelTraceEvent {
2846
/**
2947
* the severity of the trace event
3048
*/
31-
'severity'?: (_grpc_channelz_v1_ChannelTraceEvent_Severity | keyof typeof _grpc_channelz_v1_ChannelTraceEvent_Severity);
49+
'severity'?: (_grpc_channelz_v1_ChannelTraceEvent_Severity);
3250
/**
3351
* When this event occurred.
3452
*/
@@ -56,7 +74,7 @@ export interface ChannelTraceEvent__Output {
5674
/**
5775
* the severity of the trace event
5876
*/
59-
'severity': (keyof typeof _grpc_channelz_v1_ChannelTraceEvent_Severity);
77+
'severity': (_grpc_channelz_v1_ChannelTraceEvent_Severity__Output);
6078
/**
6179
* When this event occurred.
6280
*/

packages/grpc-js/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ import {
4343
loadPackageDefinition,
4444
makeClientConstructor,
4545
MethodDefinition,
46-
ProtobufTypeDefinition,
4746
Serialize,
48-
ServiceClientConstructor,
4947
ServiceDefinition,
5048
} from './make-client';
5149
import { Metadata, MetadataOptions, MetadataValue } from './metadata';

packages/grpc-js/src/internal-channel.ts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ import { ChannelOptions } from './channel-options';
2020
import { ResolvingLoadBalancer } from './resolving-load-balancer';
2121
import { SubchannelPool, getSubchannelPool } from './subchannel-pool';
2222
import { ChannelControlHelper } from './load-balancer';
23-
import {
24-
UnavailablePicker,
25-
Picker,
26-
PickResultType,
27-
QueuePicker,
28-
} from './picker';
23+
import { UnavailablePicker, Picker, QueuePicker } from './picker';
2924
import { Metadata } from './metadata';
3025
import { Status, LogVerbosity, Propagate } from './constants';
3126
import { FilterStackFactory } from './filter-stack';
@@ -36,41 +31,19 @@ import {
3631
getDefaultAuthority,
3732
mapUriDefaultScheme,
3833
} from './resolver';
39-
import { trace, log } from './logging';
34+
import { trace } from './logging';
4035
import { SubchannelAddress } from './subchannel-address';
4136
import { MaxMessageSizeFilterFactory } from './max-message-size-filter';
4237
import { mapProxyName } from './http_proxy';
43-
import { GrpcUri, parseUri, splitHostPort, uriToString } from './uri-parser';
38+
import { GrpcUri, parseUri, uriToString } from './uri-parser';
4439
import { ServerSurfaceCall } from './server-call';
45-
import { Filter } from './filter';
4640

4741
import { ConnectivityState } from './connectivity-state';
48-
import {
49-
ChannelInfo,
50-
ChannelRef,
51-
ChannelzCallTracker,
52-
ChannelzChildrenTracker,
53-
ChannelzTrace,
54-
registerChannelzChannel,
55-
SubchannelRef,
56-
unregisterChannelzRef,
57-
} from './channelz';
58-
import { Subchannel } from './subchannel';
42+
import { ChannelInfo, ChannelRef, ChannelzCallTracker, ChannelzChildrenTracker, ChannelzTrace, registerChannelzChannel, SubchannelRef, unregisterChannelzRef } from './channelz';
5943
import { LoadBalancingCall } from './load-balancing-call';
6044
import { CallCredentials } from './call-credentials';
61-
import {
62-
Call,
63-
CallStreamOptions,
64-
InterceptingListener,
65-
MessageContext,
66-
StatusObject,
67-
} from './call-interface';
68-
import { SubchannelCall } from './subchannel-call';
69-
import {
70-
Deadline,
71-
deadlineToString,
72-
getDeadlineTimeoutString,
73-
} from './deadline';
45+
import { Call, CallStreamOptions, StatusObject } from './call-interface';
46+
import { Deadline, deadlineToString } from './deadline';
7447
import { ResolvingCall } from './resolving-call';
7548
import { getNextCallNumber } from './call-number';
7649
import { restrictControlPlaneStatusCode } from './control-plane-status';

0 commit comments

Comments
 (0)