Skip to content

Conversation

@spikecurtis
Copy link
Contributor

@spikecurtis spikecurtis commented Dec 12, 2025

fixes coder/internal#1196

The above issue exposes two different bugs in Coder.

In the agent, there is a race where if the agent is closed while starting up networking, it will erroneously disconnect from Coderd, which delays or breaks writing final status and logs.

In Coderd, there is a bug where we don't properly record the latest agent disconnection time if the agent had previously disconnected. This causes us to report the agent status as "Connected" even after it has disconnected up until the inactivity timeout fires.

This PR fixes both issues.

It also slightly reworks when we send workspace updates based on connection and disconnection. Previously we would send two updates when the agent connected in certain circumstances, even though the status would be the same in both (only times changed). Now we universally only send one on connect, and then another on disconnect.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@spikecurtis spikecurtis requested a review from mafredri December 12, 2025 12:29
@spikecurtis spikecurtis marked this pull request as ready for review December 12, 2025 12:31
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

We should simplify the defer in monitor, but otherwise logic seems sound, approving. 👍🏻

@spikecurtis spikecurtis force-pushed the spike/internal-1196-agent-close branch from 476fd70 to 4277b68 Compare December 15, 2025 07:52
@spikecurtis spikecurtis merged commit 71c6dc4 into main Dec 15, 2025
31 checks passed
Copy link
Contributor Author

Merge activity

@spikecurtis spikecurtis deleted the spike/internal-1196-agent-close branch December 15, 2025 08:04
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake: coderd TestWorkspaceWatcher

2 participants