Skip to content

Commit 3e13d84

Browse files
authored
Merge pull request #2503 from murgatroid99/grpc-js_stackString_fix_fix
grpc-js: Fix an error from a previous change, and enable a TS compiler options to prevent regressions
2 parents 8d64030 + 493cbaa commit 3e13d84

27 files changed

+73
-124
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.17",
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: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ export type CheckServerIdentityCallback = (
3838
cert: PeerCertificate
3939
) => Error | undefined;
4040

41-
function bufferOrNullEqual(buf1: Buffer | null, buf2: Buffer | null) {
42-
if (buf1 === null && buf2 === null) {
43-
return true;
44-
} else {
45-
return buf1 !== null && buf2 !== null && buf1.equals(buf2);
46-
}
47-
}
48-
4941
/**
5042
* Additional peer verification options that can be set when creating
5143
* SSL credentials.
@@ -196,7 +188,7 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
196188
private verifyOptions: VerifyOptions
197189
) {
198190
super();
199-
this.connectionOptions = {
191+
this.connectionOptions = {
200192
secureContext
201193
};
202194
// Node asserts that this option is a function, so we cannot pass undefined
@@ -225,7 +217,7 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
225217
}
226218
if (other instanceof SecureChannelCredentialsImpl) {
227219
return (
228-
this.secureContext === other.secureContext &&
220+
this.secureContext === other.secureContext &&
229221
this.verifyOptions.checkServerIdentity === other.verifyOptions.checkServerIdentity
230222
);
231223
} else {

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,13 @@ export class Client {
347347
code: Status.INTERNAL,
348348
details: 'No message received',
349349
metadata: status.metadata
350-
}, /*callerStack*/''));
350+
}, callerStack));
351351
} else {
352352
callProperties.callback!(null, responseMessage);
353353
}
354354
} else {
355355
const callerStack = getErrorStackString(callerStackError!);
356-
callProperties.callback!(callErrorFromStatus(status, /*callerStack*/''));
356+
callProperties.callback!(callErrorFromStatus(status, callerStack));
357357
}
358358
/* Avoid retaining the callerStackError object in the call context of
359359
* the status event handler. */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export class CompressionFilter extends BaseFilter implements Filter {
282282
export class CompressionFilterFactory
283283
implements FilterFactory<CompressionFilter> {
284284
private sharedFilterConfig: SharedCompressionFilterConfig = {};
285-
constructor(private readonly channel: Channel, private readonly options: ChannelOptions) {}
285+
constructor(channel: Channel, private readonly options: ChannelOptions) {}
286286
createFilter(): CompressionFilter {
287287
return new CompressionFilter(this.options, this.sharedFilterConfig);
288288
}

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: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +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 { UnavailablePicker, Picker, PickResultType } from './picker';
23+
import { UnavailablePicker, Picker } from './picker';
2424
import { Metadata } from './metadata';
2525
import { Status, LogVerbosity, Propagate } from './constants';
2626
import { FilterStackFactory } from './filter-stack';
@@ -31,22 +31,19 @@ import {
3131
getDefaultAuthority,
3232
mapUriDefaultScheme,
3333
} from './resolver';
34-
import { trace, log } from './logging';
34+
import { trace } from './logging';
3535
import { SubchannelAddress } from './subchannel-address';
3636
import { MaxMessageSizeFilterFactory } from './max-message-size-filter';
3737
import { mapProxyName } from './http_proxy';
38-
import { GrpcUri, parseUri, splitHostPort, uriToString } from './uri-parser';
38+
import { GrpcUri, parseUri, uriToString } from './uri-parser';
3939
import { ServerSurfaceCall } from './server-call';
40-
import { Filter } from './filter';
4140

4241
import { ConnectivityState } from './connectivity-state';
4342
import { ChannelInfo, ChannelRef, ChannelzCallTracker, ChannelzChildrenTracker, ChannelzTrace, registerChannelzChannel, SubchannelRef, unregisterChannelzRef } from './channelz';
44-
import { Subchannel } from './subchannel';
4543
import { LoadBalancingCall } from './load-balancing-call';
4644
import { CallCredentials } from './call-credentials';
47-
import { Call, CallStreamOptions, InterceptingListener, MessageContext, StatusObject } from './call-interface';
48-
import { SubchannelCall } from './subchannel-call';
49-
import { Deadline, deadlineToString, getDeadlineTimeoutString } from './deadline';
45+
import { Call, CallStreamOptions, StatusObject } from './call-interface';
46+
import { Deadline, deadlineToString } from './deadline';
5047
import { ResolvingCall } from './resolving-call';
5148
import { getNextCallNumber } from './call-number';
5249
import { restrictControlPlaneStatusCode } from './control-plane-status';
@@ -112,7 +109,7 @@ class ChannelSubchannelWrapper extends BaseSubchannelWrapper implements Subchann
112109
}
113110

114111
export class InternalChannel {
115-
112+
116113
private resolvingLoadBalancer: ResolvingLoadBalancer;
117114
private subchannelPool: SubchannelPool;
118115
private connectivityState: ConnectivityState = ConnectivityState.IDLE;
@@ -376,7 +373,7 @@ export class InternalChannel {
376373
trace(
377374
LogVerbosity.DEBUG,
378375
'connectivity_state',
379-
'(' + this.channelzRef.id + ') ' +
376+
'(' + this.channelzRef.id + ') ' +
380377
uriToString(this.target) +
381378
' ' +
382379
ConnectivityState[this.connectivityState] +
@@ -601,7 +598,7 @@ export class InternalChannel {
601598
/**
602599
* Get the channelz reference object for this channel. The returned value is
603600
* garbage if channelz is disabled for this channel.
604-
* @returns
601+
* @returns
605602
*/
606603
getChannelzRef() {
607604
return this.channelzRef;

packages/grpc-js/src/load-balancer-outlier-detection.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ import { ConnectivityState } from "./connectivity-state";
2020
import { LogVerbosity, Status } from "./constants";
2121
import { durationToMs, isDuration, msToDuration } from "./duration";
2222
import { ChannelControlHelper, createChildChannelControlHelper, registerLoadBalancerType } from "./experimental";
23-
import { BaseFilter, Filter, FilterFactory } from "./filter";
2423
import { getFirstUsableConfig, LoadBalancer, LoadBalancingConfig, validateLoadBalancingConfig } from "./load-balancer";
2524
import { ChildLoadBalancerHandler } from "./load-balancer-child-handler";
26-
import { PickArgs, Picker, PickResult, PickResultType, QueuePicker, UnavailablePicker } from "./picker";
27-
import { Subchannel } from "./subchannel";
25+
import { PickArgs, Picker, PickResult, PickResultType } from "./picker";
2826
import { SubchannelAddress, subchannelAddressToString } from "./subchannel-address";
2927
import { BaseSubchannelWrapper, ConnectivityStateListener, SubchannelInterface } from "./subchannel-interface";
3028
import * as logging from './logging';

packages/grpc-js/src/load-balancer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
import { ChannelOptions } from './channel-options';
19-
import { Subchannel } from './subchannel';
2019
import { SubchannelAddress } from './subchannel-address';
2120
import { ConnectivityState } from './connectivity-state';
2221
import { Picker } from './picker';
@@ -58,8 +57,8 @@ export interface ChannelControlHelper {
5857
* parent while letting others pass through to the parent unmodified. This
5958
* allows other code to create these children without needing to know about
6059
* all of the methods to be passed through.
61-
* @param parent
62-
* @param overrides
60+
* @param parent
61+
* @param overrides
6362
*/
6463
export function createChildChannelControlHelper(parent: ChannelControlHelper, overrides: Partial<ChannelControlHelper>): ChannelControlHelper {
6564
return {

packages/grpc-js/src/load-balancing-call.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { SubchannelCall } from "./subchannel-call";
2121
import { ConnectivityState } from "./connectivity-state";
2222
import { LogVerbosity, Status } from "./constants";
2323
import { Deadline, getDeadlineTimeoutString } from "./deadline";
24-
import { FilterStack, FilterStackFactory } from "./filter-stack";
2524
import { InternalChannel } from "./internal-channel";
2625
import { Metadata } from "./metadata";
2726
import { PickResultType } from "./picker";
@@ -48,7 +47,6 @@ export class LoadBalancingCall implements Call {
4847
private readPending = false;
4948
private pendingMessage: {context: MessageContext, message: Buffer} | null = null;
5049
private pendingHalfClose = false;
51-
private pendingChildStatus: StatusObject | null = null;
5250
private ended = false;
5351
private serviceUrl: string;
5452
private metadata: Metadata | null = null;
@@ -104,9 +102,9 @@ export class LoadBalancingCall implements Call {
104102
}
105103
this.trace('Pick called')
106104
const pickResult = this.channel.doPick(this.metadata, this.callConfig.pickInformation);
107-
const subchannelString = pickResult.subchannel ?
108-
'(' + pickResult.subchannel.getChannelzRef().id + ') ' + pickResult.subchannel.getAddress() :
109-
'' + pickResult.subchannel;
105+
const subchannelString = pickResult.subchannel ?
106+
'(' + pickResult.subchannel.getChannelzRef().id + ') ' + pickResult.subchannel.getAddress() :
107+
'' + pickResult.subchannel;
110108
this.trace(
111109
'Pick result: ' +
112110
PickResultType[pickResult.pickResultType] +
@@ -280,4 +278,4 @@ export class LoadBalancingCall implements Call {
280278
getCallNumber(): number {
281279
return this.callNumber;
282280
}
283-
}
281+
}

0 commit comments

Comments
 (0)