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

feat: improve coder connect tunnel handling on reconnect#17598

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

Conversation

ibetitsmike
Copy link
Contributor

@ibetitsmikeibetitsmike commentedApr 29, 2025
edited
Loading

Closescoder/internal#563

TheCoder Connect tunnel receives workspace state from the Coder server over adRPC stream. When first connecting to this stream, the current state of the user's workspaces is received, with subsequent messages being diffs on top of that state.

However, if the client disconnects from this stream, such as when the user's device is suspended, and then reconnects later, no mechanism exists for the tunnel to differentiate that message containing the entire initial state from another diff, and so that state is incorrectly applied as a diff.

In practice:

  • Tunnel connects, receives a workspace update containing all the existing workspaces & agents.
  • Tunnel loses connection, but isn't completely stopped.
  • All the user's workspaces are restarted, producing a new set of agents.
  • Tunnel regains connection, and receives a workspace update containing all the existing workspaces & agents.
  • This initial update is incorrectly applied as a diff, with the Tunnel's state containing both the old & new agents.

This PR introduces a solution in which tunnelUpdater, when created, sends a FreshState flag with the WorkspaceUpdate type. This flag is handled in the vpn tunnel in the following fashion:

  • Preserve existing Agents
  • Remove current Agents in the tunnel that are not present in the WorkspaceUpdate
  • Remove unreferenced Workspaces

@ibetitsmikeibetitsmikeforce-pushed themike/internal-563-improve-coder-connect-tunnel-handling branch fromf66d81a to52f1c2bCompareApril 29, 2025 11:36
@ibetitsmikeibetitsmike changed the titleMike/internal 563 improve coder connect tunnel handlingfeat: improve coder connect tunnel handling on reconnectApr 29, 2025
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

I'm lacking context on what this change fixes. The code itself looks fine and the test coverage checks out, but deferring to Dean and Spike.

Copy link
Contributor

@spikecurtisspikecurtis left a comment

Choose a reason for hiding this comment

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

LGTM

delete(u.agents, agent.ID)
}
for _, workspace := range update.UpsertedWorkspaces {
u.workspaces[workspace.ID] = workspace.Clone()
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't actually need a full clone of the workspace, but it's probably clearer to do the legit Clone so we don't have a partially cloned object waiting to trip up some future editor of this code.

@ibetitsmikeibetitsmike merged commit5f516ed intomainMay 6, 2025
29 checks passed
@ibetitsmikeibetitsmike deleted the mike/internal-563-improve-coder-connect-tunnel-handling branchMay 6, 2025 14:00
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMay 6, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn left review comments

@spikecurtisspikecurtisspikecurtis approved these changes

@deansheatherdeansheatherdeansheather approved these changes

Assignees

@ibetitsmikeibetitsmike

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Improve Coder Connect tunnel reconnect handling
4 participants
@ibetitsmike@johnstcn@spikecurtis@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp