MCPcopy
hub / github.com/nats-io/nats.go / processTransientError

Method processTransientError

nats.go:3917–3945  ·  view source on GitHub ↗

processTransientError is called when the server signals a non terminal error which does not close the connection or trigger a reconnect. This will trigger the async error callback if set. These errors include the following: - permissions violation on publish or subscribe - maximum subscriptions exce

(err error)

Source from the content-addressed store, hash-verified

3915// - permissions violation on publish or subscribe
3916// - maximum subscriptions exceeded
3917func (nc *Conn) processTransientError(err error) {
3918 nc.mu.Lock()
3919 nc.err = err
3920 if errors.Is(err, ErrPermissionViolation) {
3921 matches := permissionsRe.FindStringSubmatch(err.Error())
3922 if len(matches) >= 2 {
3923 queueMatches := permissionsQueueRe.FindStringSubmatch(err.Error())
3924 var q string
3925 if len(queueMatches) >= 2 {
3926 q = queueMatches[1]
3927 }
3928 subject := matches[1]
3929 for _, sub := range nc.subs {
3930 if sub.Subject == subject && sub.Queue == q && sub.permissionsErr == nil {
3931 sub.mu.Lock()
3932 if sub.errCh != nil {
3933 sub.errCh <- err
3934 }
3935 sub.permissionsErr = err
3936 sub.mu.Unlock()
3937 }
3938 }
3939 }
3940 }
3941 if asyncErrorCB := nc.Opts.AsyncErrorCB; asyncErrorCB != nil {
3942 nc.ach.push(func() { asyncErrorCB(nc, nil, err) })
3943 }
3944 nc.mu.Unlock()
3945}
3946
3947// processAuthError generally processing for auth errors. We want to do retries
3948// unless we get the same error again. This allows us for instance to swap credentials

Callers 1

processErrMethod · 0.95

Calls 3

ErrorMethod · 0.65
IsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected