Fix log level for expected client disconnection scenarios (BadNoSubscription and related status codes) #3255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
When a client disconnects from the server with outstanding publish requests, the server logs warning messages like:
This is not an exceptional case and should not generate warning logs. In production environments, these warnings accumulate and spam log files, making it difficult to identify real issues that require attention.
Root Cause
When
SubscriptionManager.DeleteSubscriptionis called during client disconnection, outstanding publish requests inSessionPublishQueueare completed withBadNoSubscriptionstatus code. TheSessionPublishQueue.Publishmethod then throws aServiceResultException, which is caught byEndpointBase.CreateFault. This method was logging allServiceResultExceptioninstances at Warning level, regardless of whether they represent expected scenarios.Solution
Modified
EndpointBase.CreateFaultto log at Information level instead of Warning level for status codes that represent expected client disconnection and operational scenarios:BadNoSubscription- Client disconnects with outstanding publish requestsBadSessionClosed- Session closed normallyBadSecurityChecksFailed- Security validation failedBadCertificateInvalid- Certificate validation failedBadServerHalted- Server shutting downAll other service faults continue to log at Warning level, preserving the ability to detect unexpected issues.
Rationale
These status codes are already handled as expected scenarios in the client code (
Session.OnPublishComplete, lines 5786-5791) where they simply return without logging errors. The server-side logging should align with this behavior.Testing
Impact
Fixes issue where normal client disconnection scenarios generate excessive warning logs.
Co-authored-by: romanett 7413710+romanett@users.noreply.github.com
Original prompt
Fixes #3215
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.