Skip to content

tryShutdown results in cancelled Unary GRPCs #2091

Closed
@artificial-aidan

Description

@artificial-aidan

Problem description

When using tryShutdown to gracefully shutdown a server, it doesn't let unary RPCs finish successfully.

Reproduction steps

  1. Create GRPC server with unary handler that takes some extended amount of time
  2. Set up a process.on handler for SIGTERM
  3. Call Unary GRPC
  4. Before it completes send SIGTERM to the server process.
  5. Note that client never receives the correct response, just a cancelled call. Even though the server sends the correct data.

Environment

  • OS name, version and architecture: OSX 10.15.7
  • Node version 17.8.0
  • Package name and version grpc-js@1.3.7

Additional context

The normal process for a Unary RPC (that I can deduce from debugging) is as follows:

  1. Client opens stream to Server
  2. Client sends request to Server
  3. Server sends response to Client
  4. Client closes stream.

When using the tryShutdown method the process is different.

  1. Client opens stream to Server
  2. Client sends request to Server
  3. tryShutdown is called
  4. Server calls close on http2 session
  5. Server sends response to Client
  6. Client see's that stream has been cancelled, and errors.

The cancellation appears to be coming from the session destruction happening in tryShutdown. This makes sense for streaming GRPC calls, as they need to be cancelled, but a Unary GRPC should be able to finish its response without the call being cancelled.

Removing the session.close() from tryShutdown fixes the problem for Unary GRPCs, but obviously doesn't for Streaming GRPCs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions