Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: stop disconnecting from coderd early and record disconnect correctly#21250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
spikecurtis wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromspike/internal-1196-agent-close

Conversation

@spikecurtis
Copy link
Contributor

@spikecurtisspikecurtis commentedDec 12, 2025
edited
Loading

fixescoder/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.

@spikecurtisGraphite App
Copy link
ContributorAuthor

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@spikecurtisspikecurtis marked this pull request as ready for reviewDecember 12, 2025 12:31
Copy link
Member

@mafredrimafredri 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. 👍🏻

ifclosing {
_=network.Close()
returnxerrors.New("agent is closing")
returnErrAgentClosing
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Wrap error for consistency?

Time:dbtime.Now(),
Valid:true,
}
}()
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps a larger change than you were intending for, but wouldn't it make sense to combine these two defer's? In the current state they muddy the exit path of the routine.

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

Reviewers

@mafredrimafredrimafredri approved these changes

Assignees

@spikecurtisspikecurtis

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

flake: coderd TestWorkspaceWatcher

3 participants

@spikecurtis@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp