feat: buffer connection logs and flush them on failure - #1100
Draft
aqandrew wants to merge 4 commits into
Draft
Conversation
Wraps a Logger and keeps a bounded in-memory ring of entries below the sink's current level (the ones it would drop). flush() replays them into the sink at a level guaranteed to be written, so a connection failure can preserve the debug detail leading up to it without the user having enabled debug logging. Only below-level entries are buffered (no duplication of what the sink already writes); flush is coalesced by a short suppression window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements RFC requirement 13 / DEVEX-669: buffer connection debug logs in memory below the current log level and flush them on a genuine connection failure, so a support bundle captures the detail leading up to the failure without the user having enabled debug logging beforehand.
What this does
BufferingLoggerdecorator (src/logging/logBuffer.ts) that wraps the "Coder" output channel and keeps a bounded, in-memory ring of the log lines that sit below the channel's current level — the ones it would otherwise drop. Only below-level lines are buffered, so nothing already written is duplicated.flush(reason)re-emits the captured lines into the output channel (each marked[buffered]with its original ISO timestamp and level) at the least-verbose level the channel still persists, so they land on disk and in support bundles.ServiceContainerand adds thecoder.connectionLogBuffer.sizesetting (default1000,0disables).unrecoverable_close,unrecoverable_http,certificate_error);WorkspaceMonitorsocket error;disconnectedduring connection.CONTRIBUTING.md.Scope notes
ProxyCommandwrites its own file logs undercoder.proxyLogDirectory, which support bundles already collect from disk, so those are not buffered here.Commits
BufferingLogger+ unit testsTesting
pnpm typecheck,pnpm format:check, andpnpm lintare clean.logBuffer,reconnectingWebSocket,workspaceMonitor,workspaceStateMachine,coderApi, plus the container-mock consumers).Implementation plan & design decisions
Design
[buffered]marker plus original level/timestamp, chronologically next to the real failure logs. Support bundles already collect the on-disk VS Code logs, so no separate sink is needed.WorkspaceMonitor.notifyError, and agentdisconnected. Never on transientretryingdrops or intentional teardown (manual_disconnect,normal_close,replaced, dispose/deactivate/reload). A singleisConnectionFailure(reason)predicate gates the socket sites, and a short suppression window coalesces bursts.Logger; do not buffer CLIProxyCommandfile logs already handled viacoder.proxyLogDirectory.Decisions
[buffered]marker/original level/timestamp.Logger; not CLI ProxyCommand file logs.🤖 Generated with Coder Agents. Reviewed and authored on behalf of @aqandrew.