Visitar URL original
channel shutdown error obtrudes on network errors · Issue #12812 · grpc/grpc-java · GitHub
Skip to content

channel shutdown error obtrudes on network errors #12812

Description

@benjaminp

When a call on a gracefully-terminating ManagedClientChannel experiences a network error, the call is closed with a message suggesting the error is from channel closing rather than the network.

See my reproduction at https://github.com/benjaminp/grpc_shutdown_bug. The program in that repository

  1. starts a server
  2. makes a channel to the server
  3. starts a server-streaming call on the channel
  4. (optionally) shuts down the client channel
  5. forcibly kills the server.

When the client channel is shutdown, the client sees a UNAVAILABLE: Channel shutdown invoked error on server death:

$ ./gradlew run
> Task :run
client: launching server: build/install/streaming-demo-client/bin/streaming-demo-server
client: server pid=234110 port=44637
client: creating channel
client: starting server-streaming RPC
client: reading 1 message
May 15, 2026 3:07:05 PM io.grpc.netty.TcpMetrics loadEpollInfo
INFO: Epoll available during static init of TcpMetrics:false
May 15, 2026 3:07:05 PM io.grpc.netty.TcpMetrics loadEpollInfo
INFO: Epoll available during static init of TcpMetrics:false
client: read: 0
client: shutting down channel (graceful)
client: channel.isShutdown=true isTerminated=false
client: reading another message
client: read: 1
client: server exited with 137
client: draining until error
client: drained with error: io.grpc.StatusException: UNAVAILABLE: Channel shutdown invoked
done

Contrast with the error when the channel is not shutdown:

$ ./gradlew run --args=--noshutdown

> Task :run
client: launching server: build/install/streaming-demo-client/bin/streaming-demo-server
client: server pid=234631 port=39449
client: creating channel
client: starting server-streaming RPC
client: reading 1 message
client: read: 0
client: shutting down channel (graceful)
client: channel.isShutdown=false isTerminated=false
client: reading another message
client: read: 1
client: server exited with 137
client: draining until error
client: drained with error: io.grpc.StatusException: UNAVAILABLE: Network closed for unknown reason
done

I believe the first case should also fail with UNAVAILABLE: Network closed for unknown reason.

Activity

  1. added this to the Next milestone on May 18, 2026
  2. shivaspeaks commented on May 18, 2026

    @shivaspeaks
    Member

    We have Status precedence in ClientTransportLifecycleManager which is is designed to store the first shutdown status it receives. In the case of a graceful shutdown, the first status it receives is the one from the channel ("Channel shutdown invoked").

    When a network error occurs (e.g., the server is killed), the transport's channelInactive method is triggered. It attempts to fail all active streams with a generic "Network closed for unknown reason" status. However, before reporting the error to the streams, it checks if the lifecycleManager already has a shutdownStatus.
    Because the graceful shutdown was initiated first, the manager returns the "Channel shutdown invoked" status, and this message is reported to all active RPCs, even though they failed due to a network disconnection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions