Merge pull request #1859 from murgatroid99/grpc-js_1.3_upmerge

Upmerge from 1.3.x to master
This commit is contained in:
Michael Lumish 2021-08-12 14:54:03 -07:00 committed by GitHub
commit a6318a4d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "1.3.5",
"version": "1.3.7",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

View File

@ -658,7 +658,15 @@ export class Http2CallStream implements Call {
this.pendingWrite.length +
' (deferred)'
);
stream.write(this.pendingWrite, this.pendingWriteCallback);
try {
stream.write(this.pendingWrite, this.pendingWriteCallback);
} catch (error) {
this.endCall({
code: Status.UNAVAILABLE,
details: `Write failed with error ${error.message}`,
metadata: new Metadata()
});
}
}
this.maybeCloseWrites();
}
@ -790,7 +798,15 @@ export class Http2CallStream implements Call {
this.pendingWriteCallback = cb;
} else {
this.trace('sending data chunk of length ' + message.message.length);
this.http2Stream.write(message.message, cb);
try {
this.http2Stream.write(message.message, cb);
} catch (error) {
this.endCall({
code: Status.UNAVAILABLE,
details: `Write failed with error ${error.message}`,
metadata: new Metadata()
});
}
this.maybeCloseWrites();
}
}, this.handleFilterError.bind(this));

View File

@ -256,6 +256,12 @@ export function getProxiedConnection(
reject();
});
} else {
trace(
'Successfully established a plaintext connection to ' +
options.path +
' through proxy ' +
proxyAddressString
);
resolve({
socket,
realTarget: parsedTarget,

View File

@ -258,7 +258,10 @@ import * as resolver_ip from './resolver-ip';
import * as load_balancer_pick_first from './load-balancer-pick-first';
import * as load_balancer_round_robin from './load-balancer-round-robin';
const clientVersion = require('../../package.json').version;
(() => {
logging.trace(LogVerbosity.DEBUG, 'index', 'Loading @grpc/grpc-js version ' + clientVersion);
resolver_dns.setup();
resolver_uds.setup();
resolver_ip.setup();

View File

@ -431,7 +431,7 @@ export class Http2ServerCallStream<
private checkCancelled(): boolean {
/* In some cases the stream can become destroyed before the close event
* fires. That creates a race condition that this check works around */
if (this.stream.destroyed) {
if (this.stream.destroyed || this.stream.closed) {
this.cancelled = true;
}
return this.cancelled;

View File

@ -266,6 +266,11 @@ export class Subchannel {
}
private createSession(proxyConnectionResult: ProxyConnectionResult) {
if (proxyConnectionResult.realTarget) {
trace(this.subchannelAddressString + ' creating HTTP/2 session through proxy to ' + proxyConnectionResult.realTarget);
} else {
trace(this.subchannelAddressString + ' creating HTTP/2 session');
}
const targetAuthority = getDefaultAuthority(
proxyConnectionResult.realTarget ?? this.channelTarget
);
@ -368,6 +373,7 @@ export class Subchannel {
});
session.once('close', () => {
if (this.session === session) {
trace(this.subchannelAddressString + ' connection closed');
this.transitionToState(
[ConnectivityState.CONNECTING],
ConnectivityState.TRANSIENT_FAILURE