go-delve/delve · error
count == 0 not allowed with a channel filter
Error message
count == 0 not allowed with a channel filter
What it means
When a channel filter is present, ListGoroutines requires a non-zero Count because paging of channel waiters is computed against Count (len(gs) == arg.Count decides whether more pages exist). Count==0 would make the channel query meaningless, so it is rejected.
Source
Thrown at service/rpc2/server.go:708
// For each group a maximum of MaxGroupMembers example goroutines are
// returned, as well as the total number of goroutines in the group.
func (s *RPCServer) ListGoroutines(arg ListGoroutinesIn, out *ListGoroutinesOut) error {
//TODO(aarzilli): if arg contains a running goroutines filter (not negated)
// and start == 0 and count == 0 then we can optimize this by just looking
// at threads directly.
var gs []*proc.G
var nextg int
var err error
var gsLoaded bool
for _, filter := range arg.Filters {
if filter.Kind == api.GoroutineWaitingOnChannel {
if filter.Negated {
return errors.New("channel filter can not be negated")
}
if arg.Count == 0 {
return errors.New("count == 0 not allowed with a channel filter")
}
if arg.EvalScope == nil {
return errors.New("channel filter without eval scope")
}
gs, err = s.debugger.ChanGoroutines(arg.EvalScope.GoroutineID, arg.EvalScope.Frame, arg.EvalScope.DeferredCall, filter.Arg, arg.Start, arg.Count)
if len(gs) == arg.Count {
nextg = arg.Start + len(gs)
} else {
nextg = -1
}
gsLoaded = true
break
}
}
if !gsLoaded {
gs, nextg, err = s.debugger.Goroutines(arg.Start, arg.Count)
}View on GitHub (pinned to a23773e6c3)
Solutions
- Set Count to a positive value (e.g. page size or a large limit).
- Default Count in the client when a channel filter is requested.
- Drop the channel filter if unbounded listing is required (not supported).
Example fix
// before
in := api.ListGoroutinesIn{Filters: channelFilters} // Count defaults to 0
// after
in := api.ListGoroutinesIn{Count: 100, Filters: channelFilters} Defensive patterns
Strategy: validation
Validate before calling
if hasChannelFilter(filters) && count <= 0 {
count = 100 // sensible default
} Try / catch
err := client.Call("RPCServer.ListGoroutines", in, &out)
if err != nil && strings.Contains(err.Error(), "count == 0") {
in.Count = 100
err = client.Call("RPCServer.ListGoroutines", in, &out)
} Prevention
- Always set a positive Count when using filters.
- Default Count in your client wrapper for ListGoroutines.
- Remember channel filters page results via Start/Count.
When it happens
Trigger: ListGoroutines RPC with Filters containing Kind=GoroutineWaitingOnChannel and arg.Count == 0.
Common situations: Clients that omit Count (zero value by default) when listing goroutines, then add a channel-wait filter.
Related errors
- channel filter can not be negated
- channel filter without eval scope
- could not find goroutine array
- mismatched length in addrs and addrpid
- can not call function with nil ReturnInfoLoadConfig
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/21078791564aed9a.
Report an issue: GitHub.