Skip to content

Uncaught exception while handling HTTP2 goaway frame #2605

@pmalouin

Description

@pmalouin

Problem description

We are observing sporadic uncaught exceptions from some environments:

TypeError: Cannot read properties of undefined (reading 'equals')
  File "/app/node_modules/@grpc/grpc-js/build/src/transport.js", line 120, col 28, in ClientHttp2Session.<anonymous>
    opaqueData.equals(tooManyPingsData)) {
  File "node:events", line 632, col 26, in Object.onceWrapper
  File "node:events", line 517, col 28, in ClientHttp2Session.emit
  File "node:domain", line 489, col 12, in ClientHttp2Session.emit

Reproduction steps

Not a clear idea how to reproduce at this time, but this currently happens in environments that have very low grpc traffic, but does not happen in production/high traffic ones. I suspect that idle http2 connections are getting recycled by the server and the client is unable to handle the 'goaway' frame gracefully.

Environment

  • OS name, version and architecture: Debian 11.8
  • Node version: v18.18.2
  • Package name and version: @grpc/[email protected]

Additional context

It appears that this line of code does not account for when opaqueData is undefined. Node.js API docs do mention that this argument of the handler is optional, but perhaps subtly:

opaqueData If additional opaque data was included in the GOAWAY frame, a Buffer instance will be passed containing that data.

I also noticed that the @types/node definitions are misleading because they don't mark the argument as optional. I prepared a PR for that too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions