GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(cli): exit port-forward when workspace agent becomes unreachable by zertosh · Pull Request #24011 · coder/coder

Conversation

@zertosh

@zertosh zertosh commented Apr 3, 2026

Copy link
Copy Markdown

Fixes #10626

Previously coder port-forward kept its local listeners alive after the
tailnet connection to the agent was lost (laptop sleep, network change,
agent restart). Per-connection DialContext uses the command-lifetime
context, so AwaitReachable could block forever and the process would
accept connections into a dead backend indefinitely with no signal to
the caller.

This adds a watchdog that calls conn.AwaitReachable with a 10s timeout
every 5s once Ready! is printed. After three consecutive failures it
cancels the command context, closing all listeners and exiting non-zero,
similar to how coder ssh already closes the session via
watchAndClose when the workspace stops. Callers that want
auto-reconnect can wrap the command in a restart loop.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@zertosh
fix(cli): exit port-forward when workspace agent becomes unreachable
fd9ed7e
@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Apr 3, 2026
@github-actions

github-actions Bot commented Apr 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

zertosh reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned zertosh Apr 3, 2026
@zertosh

zertosh commented Apr 3, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cdrci2 added a commit to coder/cla that referenced this pull request Apr 3, 2026
@cdrci2
@zertosh has signed the CLA in coder/coder#24011
8c6d68a
@zertosh

zertosh commented Apr 3, 2026

Copy link
Copy Markdown
Author

recheck

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale This issue is like stale bread. label Apr 12, 2026
@sreya sreya removed the stale This issue is like stale bread. label Apr 13, 2026
sreya
sreya requested changes Apr 14, 2026
View reviewed changes

@sreya sreya left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks good for the most part, @zertosh do you have cycles to address the changes? I can take over the branch push it through to merge if you're busy as well.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread cli/portforward.go
Comment on lines +203 to +204
wg.Add(1)
go func() {

@sreya sreya Apr 14, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It'd be good to refactor this out into its own method so that we can write some unit tests for it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread cli/portforward.go
case <-ticker.C:
}
pingCtx, pingCancel := context.WithTimeout(ctx, timeout)
reachable := conn.AwaitReachable(pingCtx)

@sreya sreya Apr 14, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think we may want to use Ping() here instead of

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sreya

sreya commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

@codex review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zertosh

zertosh commented Apr 14, 2026

Copy link
Copy Markdown
Author

Please feel free to take this 😄

sreya reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sreya

sreya commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

@zertosh I'm going to close this PR in favor of the branch I created here if you want to follow along there

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sreya sreya closed this Apr 17, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 17, 2026
@sreya sreya mentioned this pull request Apr 17, 2026
feat: spawn heartbeat for agent connection during port-forward #24350
Closed
@coder coder unlocked this conversation Apr 17, 2026
@deansheather

deansheather commented Apr 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

All of our networking commands are intended to survive network connectivity loss, since the tailnet will seamlessly restore connectivity. If we make a change like this, it will mean that slept computers could terminate port forward commands even if they were still functional.

Are you seeing the connectivity break after the network is restored?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zertosh

zertosh commented Apr 18, 2026

Copy link
Copy Markdown
Author

Are you seeing the connectivity break after the network is restored?

Yeah. And it's not clear from port-forward that that is going on. The only way to know is looking for CLOSE_WAIT connections

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sreya

sreya commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

@zertosh is it enough if we log whenever we lose connectivity?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zertosh
zertosh deleted the pf_exit_dead branch May 10, 2026 00:53
@sentientmonkey sentientmonkey mentioned this pull request Oct 27, 2026
bug: stale coder ssh --stdio / coder port-forward clients retry /coordinate → 404 forever after a workspace rebuild, causing sustained authenticated load on coderd/Postgres #31370
Open
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sreya sreya sreya requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@zertosh zertosh

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

coder port-forward hangs upon workspace restart, ssh -L exits cleanly

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@zertosh @sreya @deansheather
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.