micro/go-micro · error
failed to parse client_pool_close_timeout
Error message
failed to parse client_pool_close_timeout: %v
What it means
Returned by cmd/cmd.go when the --client_pool_close_timeout flag value fails time.ParseDuration. This timeout bounds how long the client waits when draining and closing pooled connections, and invalid values abort startup before any connection is made.
Solutions
- Provide a valid duration: 10s, 500ms.
- Correct the unit casing: 10s not 10S.
- Check env/config interpolation for empty or numeric-only values.
- Omit the flag to accept the library default.
Example fix
// before --client_pool_close_timeout 10 // after --client_pool_close_timeout 10s
Defensive patterns
Strategy: validation
Validate before calling
func validDuration(s string) bool { _, err := time.ParseDuration(s); return err == nil }
if !validDuration(closeTimeout) { return fmt.Errorf("--client_pool_close_timeout must be a Go duration like 10s, got %q", closeTimeout) } Try / catch
if _, err := time.ParseDuration(t); err != nil { return fmt.Errorf("invalid client_pool_close_timeout %q: %v", t, err) } Prevention
- Use lowercase unit suffixes: 10s, 500ms.
- Never pass bare integers from env vars without a unit.
- Add smoke tests that launch the binary with production flag values.
- Omit the flag entirely when the default is acceptable.
When it happens
Trigger: Passing --client_pool_close_timeout with an invalid duration like 10 (missing unit) or 'ten seconds'.
Common situations: Copy-paste from docs where the unit was lost; scripts generating flags with default numeric values; typo like 5S (capital S is not accepted... actually 'S' is invalid; use 5s).
Understand the failure class
Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse client_pool_ttl
- failed to parse client_request_timeout
- Cannot use two forms of the same flag
- flags not parsed
- addr (nats subject) must not be empty
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/059058f0f18e9232.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/cmd.go:653
clientOpts = append(clientOpts, client.RequestTimeout(d))
}
if r := ctx.Int("client_pool_size"); r > 0 {
clientOpts = append(clientOpts, client.PoolSize(r))
}
if t := ctx.String("client_pool_ttl"); len(t) > 0 {
d, err := time.ParseDuration(t)
if err != nil {
return fmt.Errorf("failed to parse client_pool_ttl: %v", t)
}
clientOpts = append(clientOpts, client.PoolTTL(d))
}
if t := ctx.String("client_pool_close_timeout"); len(t) > 0 {
d, err := time.ParseDuration(t)
if err != nil {
return fmt.Errorf("failed to parse client_pool_close_timeout: %v", t)
}
clientOpts = append(clientOpts, client.PoolCloseTimeout(d))
}
// We have some command line opts for the server.
// Lets set it up
if len(serverOpts) > 0 {
if err := (*c.opts.Server).Init(serverOpts...); err != nil {
logger.Fatalf("Error configuring server: %v", err)
}
}
// Use an init option?
if len(clientOpts) > 0 {
if err := (*c.opts.Client).Init(clientOpts...); err != nil {
logger.Fatalf("Error configuring client: %v", err)
}
}View on GitHub (pinned to 24529f1404)