Skip to content

Commit a6318a4

Browse files
authored
Merge pull request #1859 from murgatroid99/grpc-js_1.3_upmerge
Upmerge from 1.3.x to master
2 parents 69d2140 + 770ffef commit a6318a4

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
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.3.5",
3+
"version": "1.3.7",
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: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,15 @@ export class Http2CallStream implements Call {
658658
this.pendingWrite.length +
659659
' (deferred)'
660660
);
661-
stream.write(this.pendingWrite, this.pendingWriteCallback);
661+
try {
662+
stream.write(this.pendingWrite, this.pendingWriteCallback);
663+
} catch (error) {
664+
this.endCall({
665+
code: Status.UNAVAILABLE,
666+
details: `Write failed with error ${error.message}`,
667+
metadata: new Metadata()
668+
});
669+
}
662670
}
663671
this.maybeCloseWrites();
664672
}
@@ -790,7 +798,15 @@ export class Http2CallStream implements Call {
790798
this.pendingWriteCallback = cb;
791799
} else {
792800
this.trace('sending data chunk of length ' + message.message.length);
793-
this.http2Stream.write(message.message, cb);
801+
try {
802+
this.http2Stream.write(message.message, cb);
803+
} catch (error) {
804+
this.endCall({
805+
code: Status.UNAVAILABLE,
806+
details: `Write failed with error ${error.message}`,
807+
metadata: new Metadata()
808+
});
809+
}
794810
this.maybeCloseWrites();
795811
}
796812
}, this.handleFilterError.bind(this));

packages/grpc-js/src/http_proxy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ export function getProxiedConnection(
256256
reject();
257257
});
258258
} else {
259+
trace(
260+
'Successfully established a plaintext connection to ' +
261+
options.path +
262+
' through proxy ' +
263+
proxyAddressString
264+
);
259265
resolve({
260266
socket,
261267
realTarget: parsedTarget,

packages/grpc-js/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ import * as resolver_ip from './resolver-ip';
258258
import * as load_balancer_pick_first from './load-balancer-pick-first';
259259
import * as load_balancer_round_robin from './load-balancer-round-robin';
260260

261+
const clientVersion = require('../../package.json').version;
262+
261263
(() => {
264+
logging.trace(LogVerbosity.DEBUG, 'index', 'Loading @grpc/grpc-js version ' + clientVersion);
262265
resolver_dns.setup();
263266
resolver_uds.setup();
264267
resolver_ip.setup();

packages/grpc-js/src/server-call.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ export class Http2ServerCallStream<
431431
private checkCancelled(): boolean {
432432
/* In some cases the stream can become destroyed before the close event
433433
* fires. That creates a race condition that this check works around */
434-
if (this.stream.destroyed) {
434+
if (this.stream.destroyed || this.stream.closed) {
435435
this.cancelled = true;
436436
}
437437
return this.cancelled;

packages/grpc-js/src/subchannel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ export class Subchannel {
266266
}
267267

268268
private createSession(proxyConnectionResult: ProxyConnectionResult) {
269+
if (proxyConnectionResult.realTarget) {
270+
trace(this.subchannelAddressString + ' creating HTTP/2 session through proxy to ' + proxyConnectionResult.realTarget);
271+
} else {
272+
trace(this.subchannelAddressString + ' creating HTTP/2 session');
273+
}
269274
const targetAuthority = getDefaultAuthority(
270275
proxyConnectionResult.realTarget ?? this.channelTarget
271276
);
@@ -368,6 +373,7 @@ export class Subchannel {
368373
});
369374
session.once('close', () => {
370375
if (this.session === session) {
376+
trace(this.subchannelAddressString + ' connection closed');
371377
this.transitionToState(
372378
[ConnectivityState.CONNECTING],
373379
ConnectivityState.TRANSIENT_FAILURE

0 commit comments

Comments
 (0)