From bf2009a72f7b071cb9b1605ca24646b01e9c2621 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Tue, 7 Nov 2023 11:09:59 -0800 Subject: [PATCH] grpc-js: Handle unset opaqueData in goaway event --- packages/grpc-js/package.json | 2 +- packages/grpc-js/src/transport.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/grpc-js/package.json b/packages/grpc-js/package.json index 56fa0d3ff..be29ff870 100644 --- a/packages/grpc-js/package.json +++ b/packages/grpc-js/package.json @@ -1,6 +1,6 @@ { "name": "@grpc/grpc-js", - "version": "1.9.9", + "version": "1.9.10", "description": "gRPC Library for Node - pure JS implementation", "homepage": "https://grpc.io/", "repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js", diff --git a/packages/grpc-js/src/transport.ts b/packages/grpc-js/src/transport.ts index 8dc4e2de6..39ca69383 100644 --- a/packages/grpc-js/src/transport.ts +++ b/packages/grpc-js/src/transport.ts @@ -194,17 +194,18 @@ class Http2Transport implements Transport { }); session.once( 'goaway', - (errorCode: number, lastStreamID: number, opaqueData: Buffer) => { + (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => { let tooManyPings = false; /* See the last paragraph of * https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md#basic-keepalive */ if ( errorCode === http2.constants.NGHTTP2_ENHANCE_YOUR_CALM && + opaqueData && opaqueData.equals(tooManyPingsData) ) { tooManyPings = true; } - this.trace('connection closed by GOAWAY with code ' + errorCode); + this.trace('connection closed by GOAWAY with code ' + errorCode + ' and data ' + opaqueData?.toString()); this.reportDisconnectToOwner(tooManyPings); } );