geektutu/7days-golang · error · ErrShutdown
connection is shut down
Error message
connection is shut down
What it means
Sentinel error ErrShutdown (io.Closer semantics) indicating the client connection is no longer usable: either the user called Close (closing=true) or the server told the client to stop (shutdown=true). Returned by Close when already closing and used to fail pending calls.
Source
Thrown at gee-rpc/day3-service/client.go:50
// Client represents an RPC Client.
// There may be multiple outstanding Calls associated
// with a single Client, and a Client may be used by
// multiple goroutines simultaneously.
type Client struct {
cc codec.Codec
opt *Option
sending sync.Mutex // protect following
header codec.Header
mu sync.Mutex // protect following
seq uint64
pending map[uint64]*Call
closing bool // user has called Close
shutdown bool // server has told us to stop
}
var _ io.Closer = (*Client)(nil)
var ErrShutdown = errors.New("connection is shut down")
// Close the connection
func (client *Client) Close() error {
client.mu.Lock()
defer client.mu.Unlock()
if client.closing {
return ErrShutdown
}
client.closing = true
return client.cc.Close()
}
// IsAvailable return true if the client does work
func (client *Client) IsAvailable() bool {
client.mu.Lock()
defer client.mu.Unlock()
return !client.shutdown && !client.closing
}View on GitHub (pinned to cf36443821)
Solutions
- Do not use the Client after calling Close; create a new one via Dial.
- Check for errors.Is(err, ErrShutdown) and reconnect with a fresh client.
- For graceful restarts, drain outstanding Call.Done channels before closing the client.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at gee-rpc/day3-service/client.go:50 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of geektutu/7days-golang@cf36443821 (2026-09-03).
Data as JSON: /api/errors/e4ee8d4d27318956.
Report an issue: GitHub.