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: auto reconnect the terminal#18796

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

Merged
BrunoQuaresma merged 8 commits intomainfrombq/auto-reconnect-terminal
Jul 9, 2025

Conversation

BrunoQuaresma
Copy link
Collaborator

@BrunoQuaresmaBrunoQuaresma commentedJul 8, 2025
edited
Loading

Changes:

  • Usewebsocket-ts to have auto reconnection out of the box 🙏
  • Update the disconnected alert message to "Trying to connect..." since the connection is always trying to reconnect
  • RemoveuseWithRetry because it is not necessary anymore

Other topics:

  • The disconnected alert is displaying a simple message, but we can include more info such as the number of attemtps
  • The reconnection feature is in a good state and adding value. IMO, any improvement can be done after getting this merged

Closescoder/internal#659

code-asher reacted with thumbs up emoji
@BrunoQuaresma
Copy link
CollaboratorAuthor

@code-asher I'm wondering if we can stop adding error messages to the terminal since we already have the alert. Wdyt?

Screenshot 2025-07-08 at 11 58 37

@code-asher
Copy link
Member

I'm wondering if we can stop adding error messages to the terminal since we already have the alert. Wdyt?

Makes perfect sense to me!

Copy link
Member

@code-ashercode-asher left a comment
edited
Loading

Choose a reason for hiding this comment

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

Looks promising! I tried it out and it seems to reconnect but then I was unable to see anything show up in the terminal. Is that the same for you? I can see messages being sent and received on the web socket, so it seems like we are just not printing to the terminal anymore. Maybe we have to rebind something? Or maybe the terminal is being recreated or something.

@@ -259,9 +266,11 @@ const TerminalPage: FC = () => {
if (disposed) {
return; // Unmounted while we waited for the async call.
}
websocket = new WebSocket(url);
websocket = new WebsocketBuilder(url)
.withBackoff(new ConstantBackoff(1000))
Copy link
Member

Choose a reason for hiding this comment

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

I think we should switch this to exponential (ideally with some jitter) soon, if not in this PR. A fixed reconnect interval is a good way to DDoS yourself 😆

@code-asher
Copy link
Member

Ah actually it seems the data is a blob after reconnect instead of a array buffer? Doeswebsocket-ts not preserve thebinaryType? Maybe we have to set it again on reconnect.

Also we should probably send the size on reconnect in case the user resized the terminal while offline.

BrunoQuaresma reacted with thumbs up emoji

@BrunoQuaresma
Copy link
CollaboratorAuthor

@code-asher fixed the issues you pointed out. I tested using the following steps:

  • Open the terminal
  • Runtop
  • Put network on offline using the dev console (in network tab)
  • Enable network again

Do you know if this is a good recipe for testing these changes? Let me know if you think I should test this differently.

Copy link
Member

@code-ashercode-asher left a comment

Choose a reason for hiding this comment

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

It works! I wish their backoff implementation had jitter, but what can ya do. We can add our own backoff implementation later if necessary.

Put network on offline using the dev console (in network tab)

My experience has been that this setting does not affect existing connections (like web sockets). I tried just now to be sure (in Chromium) but the "trying to connect" message never appears and I can still use the terminal even when "offline".

What I have been doing is killing coderd, waiting for the reconnect message, then starting coderd again.

BrunoQuaresma reacted with heart emoji
@BrunoQuaresmaBrunoQuaresma merged commit5a8a19b intomainJul 9, 2025
31 checks passed
@BrunoQuaresmaBrunoQuaresma deleted the bq/auto-reconnect-terminal branchJuly 9, 2025 18:04
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJul 9, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@code-ashercode-ashercode-asher approved these changes

Assignees

@BrunoQuaresmaBrunoQuaresma

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

tasks: terminal should try to reconnect
2 participants
@BrunoQuaresma@code-asher

[8]ページ先頭

©2009-2025 Movatter.jp