nats-io/nats-server · error

%v

Error message

%v

What it means

Emitted by the warn helper inside the async consumer-cleanup goroutine (deleting a source/mirror consumer during stream teardown when the owning account differs). It wraps failures such as JSON unmarshal of the delete response, reporting which account/stream/consumer cleanup failed and why; the goroutine then gives up for that consumer.

Source

Thrown at server/stream.go:3043

		subject = strings.Replace(subject, JSApiPrefix, source.External.ApiPrefix, 1)
		subject = strings.ReplaceAll(subject, "..", ".")
	}
	s := mset.srv
	go func() {
		warn := func(err error) {
			if log {
				s.Warnf("Cleanup of %s consumer '%s > %s' failed for stream '%s > %s': %v", kind, sourceName, consumerName, accName, streamName, err)
			}
		}

		respCh := make(chan *JSApiConsumerDeleteResponse, 1)
		reply := infoReplySubject()
		cdSub, err := acc.subscribeInternal(reply, func(sub *subscription, c *client, _ *Account, subject, reply string, rmsg []byte) {
			_, msg := c.msgParts(rmsg)

			var cdr JSApiConsumerDeleteResponse
			if err := json.Unmarshal(msg, &cdr); err != nil {
				warn(err)
				return
			}
			select {
			case respCh <- &cdr:
			default:
			}
		})
		if err != nil {
			warn(err)
			return
		}
		defer acc.unsubscribeInternal(cdSub)

		// Send the delete request.
		err = s.sendInternalAccountMsgWithReply(acc, subject, reply, nil, nil, false)
		if err != nil {
			warn(err)
			return

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Check the wrapped error (malformed response usually indicates a protocol/version mismatch)
  2. Manually delete the leftover consumer via the JS API if it persists
  3. Upgrade mismatched clusters so internal delete responses parse correctly
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at server/stream.go:3043 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/a7dfb0cd7e47483e. Report an issue: GitHub.