Skip to content

fix: log websocket session termination at Warn level during reconnection cycles in Client.Run - #187

Open
nudgebee-dev[bot] wants to merge 1 commit into
mainfrom
fix/log-websocket-session-termination-warn-1793985320
Open

nudgebee-dev[bot] wants to merge 1 commit into
mainfrom
fix/log-websocket-session-termination-warn-1793985320

Conversation

@nudgebee-dev

@nudgebee-dev nudgebee-dev Bot commented Nov 6, 2026

Copy link
Copy Markdown

Description

In pkg/ws/client.go within Client.Run, transient WebSocket session disconnects and connection terminations are logged at Error level using c.logger.Error("websocket session ended", "err", err). Because Client.Run automatically manages reconnections via exponential backoff, transient network drops and routine session resets are recoverable events rather than fatal errors. Logging them as Error triggers false-positive alerts by incrementing container_log_messages_total{level="error"}. Changing this log statement to c.logger.Warn("websocket session ended", "err", err) appropriately categorizes transient disconnects while maintaining observability during reconnection loops.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking change which improves existing functionality)
  • Refactor (non-breaking change which improves code structure)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation
  • CI/CD

Original Error/Logs

Click to expand the original error that triggered this fix
In pkg/ws/client.go inside Client.Run, change `c.logger.Error("websocket session ended", "err", err)` to log at Warn or Info level during normal reconnection cycles, or differentiate between unexpected internal fatal errors and network disconnects. This prevents transient connection drops from incrementing container_log_messages_total{level="error"}.

Files located during the investigation: pkg/ws/client.go

The investigation already read this code:
**Code examined**

- `pkg/ws/client.go`:120-123 — Logging site where any error from connectAndServe is logged at error level

err := c.connectAndServe(ctx)
if err != nil {
c.logger.Error("websocket session ended", "err", err)
}


- `pkg/ws/client.go`:269-275 — Read loop returning error on any disconnect not marked normal closure or going away

_, msg, err := conn.ReadMessage()
if err != nil {
if websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway) {
return nil
}
return fmt.Errorf("read error: %w", err)
}



If part of the requested change is already present in the code above, do not repeat it: implement the part that is missing. If the whole request is already satisfied, make no change and report that, citing the code that satisfies it.

How Has This Been Tested?

  • Unit tests
  • Manual testing

Checklist

  • CLA signed (the CLA bot will prompt on your first PR)
  • make validate passes (fmt + lint + test)
  • Docs updated if the wire shape, config surface, or proxy module behavior changed

🤖 This PR was automatically generated by NudgeBee AI coding agent

Powered by AI-driven code analysis and automated fix generation

🔍 View Original Investigation

Click the link above to see the full investigation and analysis that led to this fix

View Detailed Nubi Conversation


✅ Verification

Build verification passed for the affected modules.

Commands run
PASSED (cd . && go build ./...) exit=0

Downgrade the log level from Error to Warn when a WebSocket session ends
in Client.Run. Since Client.Run handles automatic reconnections via
exponential backoff, transient network drops and routine session resets
are recoverable events. Logging them at Error triggers false-positive
alerts on error log metrics.
@nudgebee-dev
nudgebee-dev Bot force-pushed the fix/log-websocket-session-termination-warn-1793985320 branch from 3901125 to 4102d1e Compare November 6, 2026 18:12
@nudgebee-dev

nudgebee-dev Bot commented Nov 6, 2026

Copy link
Copy Markdown
Author

Nudgebee Automated Followup

Resolved CI vuln check failure by updating github.com/andybalholm/brotli to v1.2.7 and github.com/klauspost/compress to v1.20.2 in go.mod and go.sum. Verified govulncheck and tests pass cleanly, then amended and pushed the commit to origin/fix/log-websocket-session-termination-warn-1793985320.

Commit: 4102d1ea3d44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant