Skip to content

Commit 770ffef

Browse files
committed
Merge remote-tracking branch 'upstream/@grpc/[email protected]' into grpc-js_1.3_upmerge
2 parents 6161950 + 5db8649 commit 770ffef

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-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.6",
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
@@ -660,7 +660,15 @@ export class Http2CallStream implements Call {
660660
this.pendingWrite.length +
661661
' (deferred)'
662662
);
663-
stream.write(this.pendingWrite, this.pendingWriteCallback);
663+
try {
664+
stream.write(this.pendingWrite, this.pendingWriteCallback);
665+
} catch (error) {
666+
this.endCall({
667+
code: Status.UNAVAILABLE,
668+
details: `Write failed with error ${error.message}`,
669+
metadata: new Metadata()
670+
});
671+
}
664672
}
665673
this.maybeCloseWrites();
666674
}
@@ -788,7 +796,15 @@ export class Http2CallStream implements Call {
788796
this.pendingWriteCallback = cb;
789797
} else {
790798
this.trace('sending data chunk of length ' + message.message.length);
791-
this.http2Stream.write(message.message, cb);
799+
try {
800+
this.http2Stream.write(message.message, cb);
801+
} catch (error) {
802+
this.endCall({
803+
code: Status.UNAVAILABLE,
804+
details: `Write failed with error ${error.message}`,
805+
metadata: new Metadata()
806+
});
807+
}
792808
this.maybeCloseWrites();
793809
}
794810
}, this.handleFilterError.bind(this));

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;

0 commit comments

Comments
 (0)