nats-io/nats-server · error

sublist: nil channel

Error message

sublist: nil channel

What it means

RegisterNotification was called with a nil notification channel — the sublist cannot register reconfiguration interest without a channel, so the nil guard returns ErrNilChan immediately.

Source

Thrown at server/sublist.go:45

// provides a facility to match subjects from published messages to
// interested subscribers. Subscribers can have wildcard subjects to
// match multiple published subjects.

// Common byte variables for wildcards and token separator.
const (
	pwc   = '*'
	pwcs  = "*"
	fwc   = '>'
	fwcs  = ">"
	tsep  = "."
	btsep = '.'
)

// Sublist related errors
var (
	ErrInvalidSubject    = errors.New("sublist: invalid subject")
	ErrNotFound          = errors.New("sublist: no matches found")
	ErrNilChan           = errors.New("sublist: nil channel")
	ErrAlreadyRegistered = errors.New("sublist: notification already registered")
)

const (
	// cacheMax is used to bound limit the frontend cache
	slCacheMax = 1024
	// If we run a sweeper we will drain to this count.
	slCacheSweep = 256
	// plistMin is our lower bounds to create a fast plist for Match.
	plistMin = 256
)

// SublistResult is a result structure better optimized for queue subs.
type SublistResult struct {
	psubs []*subscription
	qsubs [][]*subscription // don't make this a map, too expensive to iterate
}

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Pass a non-nil (buffered) notification channel
  2. Skip registration when no notifications are needed
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at server/sublist.go:45 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/5f0032c5b5878524. Report an issue: GitHub.