Skip to content

Commit 312fb9b

Browse files
committed
Merge remote-tracking branch 'upstream/@grpc/[email protected]' into v1.5.x_upmerge
2 parents 7239c0e + ec334f2 commit 312fb9b

18 files changed

+276
-36
lines changed

doc/environment_variables.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ can be set.
3636
- `server` - Traces high-level server events
3737
- `server_call` - Traces server handling of individual requests
3838
- `subchannel` - Traces subchannel connectivity state and errors
39-
- `subchannel_refcount` - Traces subchannel refcount changes
39+
- `subchannel_refcount` - Traces subchannel refcount changes. Includes per-call logs.
40+
- `subchannel_flowctrl` - Traces HTTP/2 flow control. Includes per-call logs.
41+
- `subchannel_internals` - Traces HTTP/2 session state. Includes per-call logs.
42+
- `channel_stacktrace` - Traces channel construction events with stack traces.
4043

4144
The following tracers are added by the `@grpc/grpc-js-xds` library:
4245
- `cds_balancer` - Traces the CDS load balancing policy

packages/grpc-js-xds/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ const client = new MyServiceClient('xds:///example.com:123');
2626
- [xDS v3 API](https://github.com/grpc/proposal/blob/master/A30-xds-v3.md)
2727
- [xDS Timeouts](https://github.com/grpc/proposal/blob/master/A31-xds-timeout-support-and-config-selector.md)
2828
- [xDS Circuit Breaking](https://github.com/grpc/proposal/blob/master/A32-xds-circuit-breaking.md)
29-
- [xDS Client-Side Fault Injection](https://github.com/grpc/proposal/blob/master/A33-Fault-Injection.md)
29+
- [xDS Client-Side Fault Injection](https://github.com/grpc/proposal/blob/master/A33-Fault-Injection.md)
30+
- [Client Status Discovery Service](https://github.com/grpc/proposal/blob/master/A40-csds-support.md)

packages/grpc-js-xds/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grpc/grpc-js-xds",
3-
"version": "1.4.0",
3+
"version": "1.5.2",
44
"description": "Plugin for @grpc/grpc-js. Adds the xds:// URL scheme and associated features.",
55
"main": "build/src/index.js",
66
"scripts": {
@@ -47,14 +47,15 @@
4747
"re2-wasm": "^1.0.1"
4848
},
4949
"peerDependencies": {
50-
"@grpc/grpc-js": "~1.4.0"
50+
"@grpc/grpc-js": "~1.5.0"
5151
},
5252
"engines": {
5353
"node": ">=10.10.0"
5454
},
5555
"files": [
5656
"src/**/*.ts",
5757
"build/src/**/*.{js,d.ts,js.map}",
58+
"deps/envoy-api/envoy/admin/v3/**/*.proto",
5859
"deps/envoy-api/envoy/api/v2/**/*.proto",
5960
"deps/envoy-api/envoy/config/**/*.proto",
6061
"deps/envoy-api/envoy/service/**/*.proto",

packages/grpc-js/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Many channel arguments supported in `grpc` are not supported in `@grpc/grpc-js`.
5656
- `grpc.max_send_message_length`
5757
- `grpc.max_receive_message_length`
5858
- `grpc.enable_http_proxy`
59+
- `grpc.default_compression_algorithm`
60+
- `grpc.enable_channelz`
5961
- `grpc-node.max_session_memory`
6062
- `channelOverride`
6163
- `channelFactoryOverride`

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.4.6",
3+
"version": "1.5.9",
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/call-stream.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ export class Http2CallStream implements Call {
312312
const filteredStatus = this.filterStack.receiveTrailers(
313313
this.finalStatus!
314314
);
315+
this.trace(
316+
'ended with status: code=' +
317+
filteredStatus.code +
318+
' details="' +
319+
filteredStatus.details +
320+
'"'
321+
);
315322
this.statusWatchers.forEach(watcher => watcher(filteredStatus));
316323
/* We delay the actual action of bubbling up the status to insulate the
317324
* cleanup code in this class from any errors that may be thrown in the
@@ -346,13 +353,6 @@ export class Http2CallStream implements Call {
346353
/* If the status is OK and a new status comes in (e.g. from a
347354
* deserialization failure), that new status takes priority */
348355
if (this.finalStatus === null || this.finalStatus.code === Status.OK) {
349-
this.trace(
350-
'ended with status: code=' +
351-
status.code +
352-
' details="' +
353-
status.details +
354-
'"'
355-
);
356356
this.finalStatus = status;
357357
this.maybeOutputStatus();
358358
}
@@ -795,6 +795,10 @@ export class Http2CallStream implements Call {
795795
this.filterStack.push(extraFilters);
796796
}
797797

798+
getCallNumber() {
799+
return this.callNumber;
800+
}
801+
798802
startRead() {
799803
/* If the stream has ended with an error, we should not emit any more
800804
* messages and we should communicate that the stream has ended */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export interface ChannelOptions {
3636
'grpc.max_send_message_length'?: number;
3737
'grpc.max_receive_message_length'?: number;
3838
'grpc.enable_http_proxy'?: number;
39+
/* http_connect_target and http_connect_creds are used for passing data
40+
* around internally, and should not be documented as public-facing options
41+
*/
3942
'grpc.http_connect_target'?: string;
4043
'grpc.http_connect_creds'?: string;
4144
'grpc.default_compression_algorithm'?: CompressionAlgorithms;

packages/grpc-js/src/channel.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ export class ChannelImplementation implements Channel {
336336
new CompressionFilterFactory(this, this.options),
337337
]);
338338
this.trace('Channel constructed with options ' + JSON.stringify(options, undefined, 2));
339+
const error = new Error();
340+
trace(LogVerbosity.DEBUG, 'channel_stacktrace', '(' + this.channelzRef.id + ') ' + 'Channel constructed \n' + error.stack?.substring(error.stack.indexOf('\n')+1));
339341
}
340342

341343
private getChannelzInfo(): ChannelInfo {
@@ -405,11 +407,16 @@ export class ChannelImplementation implements Channel {
405407
metadata: callMetadata,
406408
extraPickInfo: callConfig.pickInformation,
407409
});
410+
const subchannelString = pickResult.subchannel ?
411+
'(' + pickResult.subchannel.getChannelzRef().id + ') ' + pickResult.subchannel.getAddress() :
412+
'' + pickResult.subchannel;
408413
this.trace(
409-
'Pick result: ' +
414+
'Pick result for call [' +
415+
callStream.getCallNumber() +
416+
']: ' +
410417
PickResultType[pickResult.pickResultType] +
411418
' subchannel: ' +
412-
pickResult.subchannel?.getAddress() +
419+
subchannelString +
413420
' status: ' +
414421
pickResult.status?.code +
415422
' ' +
@@ -434,7 +441,7 @@ export class ChannelImplementation implements Channel {
434441
log(
435442
LogVerbosity.ERROR,
436443
'Error: COMPLETE pick result subchannel ' +
437-
pickResult.subchannel!.getAddress() +
444+
subchannelString +
438445
' has state ' +
439446
ConnectivityState[pickResult.subchannel!.getConnectivityState()]
440447
);
@@ -462,9 +469,9 @@ export class ChannelImplementation implements Channel {
462469
callConfig.onCommitted?.();
463470
pickResult.onCallStarted?.();
464471
} catch (error) {
465-
if (
466-
(error as NodeJS.ErrnoException).code ===
467-
'ERR_HTTP2_GOAWAY_SESSION'
472+
const errorCode = (error as NodeJS.ErrnoException).code;
473+
if (errorCode === 'ERR_HTTP2_GOAWAY_SESSION' ||
474+
errorCode === 'ERR_HTTP2_INVALID_SESSION'
468475
) {
469476
/* An error here indicates that something went wrong with
470477
* the picked subchannel's http2 stream right before we
@@ -481,7 +488,7 @@ export class ChannelImplementation implements Channel {
481488
* tryPick */
482489
this.trace(
483490
'Failed to start call on picked subchannel ' +
484-
pickResult.subchannel!.getAddress() +
491+
subchannelString +
485492
' with error ' +
486493
(error as Error).message +
487494
'. Retrying pick',
@@ -491,7 +498,7 @@ export class ChannelImplementation implements Channel {
491498
} else {
492499
this.trace(
493500
'Failed to start call on picked subchanel ' +
494-
pickResult.subchannel!.getAddress() +
501+
subchannelString +
495502
' with error ' +
496503
(error as Error).message +
497504
'. Ending call',
@@ -510,7 +517,7 @@ export class ChannelImplementation implements Channel {
510517
* block above */
511518
this.trace(
512519
'Picked subchannel ' +
513-
pickResult.subchannel!.getAddress() +
520+
subchannelString +
514521
' has state ' +
515522
ConnectivityState[subchannelState] +
516523
' after metadata filters. Retrying pick',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ export class ChildLoadBalancerHandler implements LoadBalancer {
125125
}
126126
exitIdle(): void {
127127
if (this.currentChild) {
128-
this.currentChild.resetBackoff();
128+
this.currentChild.exitIdle();
129129
if (this.pendingChild) {
130-
this.pendingChild.resetBackoff();
130+
this.pendingChild.exitIdle();
131131
}
132132
}
133133
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,15 @@ export class PickFirstLoadBalancer implements LoadBalancer {
449449
destroy() {
450450
this.resetSubchannelList();
451451
if (this.currentPick !== null) {
452-
this.currentPick.unref();
453-
this.currentPick.removeConnectivityStateListener(
452+
/* Unref can cause a state change, which can cause a change in the value
453+
* of this.currentPick, so we hold a local reference to make sure that
454+
* does not impact this function. */
455+
const currentPick = this.currentPick;
456+
currentPick.unref();
457+
currentPick.removeConnectivityStateListener(
454458
this.pickedSubchannelStateListener
455459
);
456-
this.channelControlHelper.removeChannelzChild(this.currentPick.getChannelzRef());
460+
this.channelControlHelper.removeChannelzChild(currentPick.getChannelzRef());
457461
}
458462
}
459463

0 commit comments

Comments
 (0)