hyperledger/fabric · error
Timeout should be specified
Error message
Timeout should be specified
What it means
Gossip's SendByCriteria requires the SendCriteria to carry a non-zero Timeout, because it forwards the timeout to the underlying comm layer (SendWithAck) for ack-based delivery. A zero Timeout makes the send duration undefined, so the call is rejected immediately before any network activity.
Source
Thrown at gossip/gossip/gossip_impl.go:631
if msg.filter(peer.PKIID) {
result = append(result, peer)
}
}
return result
}
// IdentityInfo returns information known peer identities
func (g *Node) IdentityInfo() api.PeerIdentitySet {
return g.idMapper.IdentityInfo()
}
// SendByCriteria sends a given message to all peers that match the given SendCriteria
func (g *Node) SendByCriteria(msg *protoext.SignedGossipMessage, criteria SendCriteria) error {
if criteria.MaxPeers == 0 {
return nil
}
if criteria.Timeout == 0 {
return errors.New("Timeout should be specified")
}
if criteria.IsEligible == nil {
criteria.IsEligible = filter.SelectAllPolicy
}
membership := g.disc.GetMembership()
if len(criteria.Channel) > 0 {
gc := g.chanState.getGossipChannelByChainID(criteria.Channel)
if gc == nil {
return fmt.Errorf("requested to Send for channel %s, but no such channel exists", criteria.Channel)
}
membership = gc.GetPeers()
}
peers2send := filter.SelectPeers(criteria.MaxPeers, membership, criteria.IsEligible)
if len(peers2send) < criteria.MinAck {View on GitHub (pinned to 2736b63f8f)
Solutions
- Set criteria.Timeout to an explicit duration (e.g. time.Second * 5) before calling SendByCriteria
- Derive the timeout from an existing config value (timeout ranges used elsewhere in gossip) instead of a zero literal
- If you truly want fire-and-forget behavior, use a different send API rather than passing zero Timeout
Example fix
// before
err := g.SendByCriteria(msg, discovery.SendCriteria{Channel: chanID, MaxPeers: 3, MinAck: 2})
// after
err := g.SendByCriteria(msg, discovery.SendCriteria{Channel: chanID, MaxPeers: 3, MinAck: 2, Timeout: 5 * time.Second}) Defensive patterns
Strategy: validation
Validate before calling
if criteria.MaxPeers > 0 && criteria.Timeout == 0 {
return errors.New("SendCriteria.Timeout must be set")
}
err := g.SendByCriteria(msg, criteria) Try / catch
if err := g.SendByCriteria(msg, criteria); err != nil && strings.Contains(err.Error(), "Timeout should be specified") {
criteria.Timeout = 5 * time.Second
err = g.SendByCriteria(msg, criteria)
} Prevention
- Always set Timeout in SendCriteria literals; make a constructor helper that enforces it
- Use a shared default timeout constant in your codebase
- Enable linters that flag zero-value time.Duration usage
When it happens
Trigger: Calling Node.SendByCriteria with a SendCriteria literal that omits Timeout (zero value) while MaxPeers is non-zero — e.g. constructing criteria with only Channel/MaxPeers/MinAck set.
Common situations: Unit tests (TestSendByCriteria) or application code building SendCriteria structs where the Timeout field is forgotten or assumed to default to something sensible.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- block from orderer could not be re-marshaled: proto: Marshal
- group %s isn't mapped to endorsers, but exists in a layout
- failed creating endorser object
- received empty envelope(s) for endorsers for chaincode %s, c
- failed unmarshalling gossip envelope to alive message
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/6079daef43c13720.
Report an issue: GitHub.