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

  1. Set criteria.Timeout to an explicit duration (e.g. time.Second * 5) before calling SendByCriteria
  2. Derive the timeout from an existing config value (timeout ranges used elsewhere in gossip) instead of a zero literal
  3. 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

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.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/6079daef43c13720. Report an issue: GitHub.