Skip to content

Silently attempt automatic reconnect before displaying popup for reload. #1791

Closed
@GrahamDumpleton

Description

@GrahamDumpleton

Right now if the web socket connection to the backend is lost, a popup will be displayed looking like:

image

If you don't click on any buttons it will disappear after about five seconds and reconnect anyway.

This behaviour of displaying the popup immediately when the connection is lost is very frustrating with certain deployments.

In particular when code-server is deployed to Kubernetes, where Kubernetes is using nginx as the ingress controller, this can result in the popup displayed in the worst case about every 4 to 5 minutes.

The reason for this is that every time a new ingress is added to the Kubernetes cluster, nginx has to reload the configuration, and nginx in doing a configuration reload will shutdown any active connections after a grace period. That default grace period is 240 seconds.

This means in a very active Kubernetes cluster, such as one hosting a training portal or workspace environment where the code-server editor is used and people come and go very frequently, all code-server sessions on the cluster get a stream of these popups occurring, which can get frustrating quite quickly when people are active in the editor a lot of the time.

Suggestion as a new feature therefore is to change the behaviour such that if the connection is lost, instead of immediately displaying the popup, attempt to reconnect with a delay of 100-250ms, with retries up to a period of 1 second. Only after multiple failures to reconnect when the 1 second expires, then display the popup.

This means reconnection can be handled transparently without the user needing to know, in cases where the loss of the connection is transient due to a reload in any routing layer in front of the backend. Users will therefore not be interrupted by the popup all the time.

If concerned about there being no indication at all that a reload was performed, then add a little icon in the bottom status bar which indicates connection state. When the connection is lost first change the status icon to indicate loss of connection. If the automatic retries within the 1 second period work, then set the status icon back to things being okay. If the 1 second expires then display the popup.

Since can't seem to find any settings in code-server which otherwise control the behaviour around reconnects, the only other option to reduce the annoyance of the popups that know of is to suggest to people to override the Kubernetes ingress controller configuration globally for the cluster to increase the grace periods from 240s to a longer duration.

This is something that might be able to do if your own cluster and is dedicated mainly to hosting the workspaces which use code-server, but usually isn't going to be something people would want to change if other workloads are run, as it can have implications with the amount of memory nginx ends up using.

So hoping would consider implementing automatic reconnect attempts before displaying popup.

If there is already a setting to enable such a feature, can you please indicate what it is. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions