Quiet recoverable server-error logs#1148
Conversation
|
Claude finished @mtmk's task in 1m 37s —— View job PR Review: Quiet recoverable server-error logs
|
buffer.GetOffset(position.Value) returns the segment-internal index instead of the offset relative to buffer.Start when the sequence comes from SeqeunceBuilder's multi-segment constructor and the buffer has been sliced (e.g. after a PONG was consumed from the same read). That made buffer.Slice(0, GetOffset - 1) throw ArgumentOutOfRange, so the -ERR was never logged. Use SequencePosition-based slicing, which honours the sliced view.
|
Claude finished @mtmk's task in 1m 50s —— View job Review of commit
|
| NatsServerErrorKind.StaleConnection => LogLevel.Debug, | ||
| _ => LogLevel.Error, | ||
| }; | ||
| _logger.Log(level, NatsLogEvents.Protocol, "Server error {Error}", error); |
There was a problem hiding this comment.
Since it's not an error, maybe change the message? Also, doesn't the user already have a way to monitor connections state and do their own logging?

Server-initiated graceful disconnects (User/Account Authentication Expired, Authentication Revoked, Stale Connection) are expected and recovered by the client's normal reconnect flow. Logging them at Error every 15 minutes (common with auth-callout JWTs) creates noise in monitoring without indicating an actual problem. They now log at Debug; other -ERR kinds (Permissions Violation, Maximum Connections, etc.) continue to log at Error. The
ServerErrorevent still fires for every kind, so callers wanting visibility can subscribe. Matches the nats.go behaviour of not surfacing these as errors and routing them through a callback instead.The unobserved-exception part of the same issue was already fixed by #1051; the new test pins both behaviours.
The new test also exposed a pre-existing bug in -ERR parsing: when PONG and -ERR arrived in the same TCP read,
buffer.GetOffset(position.Value)on the post-PONG slice returned the segment-internal index instead of the offset relative to the slice start, soSlice(0, GetOffset - 1)threwArgumentOutOfRangeExceptionand the server error was never logged or signalled. Switched toSequencePosition-based slicing.Fixes #847