code-server: Cannot automatically reconnect when code-server restarts

  • Web Browser: Microsoft Edge/Chrome
  • Local OS: MacOS BigSur 11.
  • Remote OS: Ubuntu Linux (Linux dev-box 5.4.0-1037-oracle #40-Ubuntu SMP Thu Jan 14 09:19:02 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux)
  • Remote Architecture: amd64
  • code-server --version: 3.8.1 41ad0c0c4c14df78e1bfa3a44d8b633ed2fc26e5

The service by itself starts up fine. Later on when I try to connect to the remote server I keep seeing this error over and over again in the systemd logs.

ubuntu@dev-box:~$ journalctl -u code-server@ubuntu | tail
Feb 08 22:14:58 dev-box code-server[2710]:     at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
Feb 08 22:14:58 dev-box code-server[2710]:     at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
Feb 08 22:14:58 dev-box code-server[2710]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
Feb 08 22:15:08 dev-box code-server[2710]: [2021-02-08T16:45:08.475Z] error vscode is not running Error: vscode is not running
Feb 08 22:15:08 dev-box code-server[2710]:     at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
Feb 08 22:15:08 dev-box code-server[2710]:     at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
Feb 08 22:15:08 dev-box code-server[2710]:     at step (/usr/lib/code-server/out/node/vscode.js:63:23)
Feb 08 22:15:08 dev-box code-server[2710]:     at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
Feb 08 22:15:08 dev-box code-server[2710]:     at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
Feb 08 22:15:08 dev-box code-server[2710]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)

Let me know if you need any other logs/information, I’ll be happy to provide them for you.

Updated Workaround: Essentially if code-server crashes and recovers you’ll have to close your code-server browser window and restart it again in the background.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (8 by maintainers)

Most upvoted comments

@jsjoeio, as @walterreade rightly pointed out, this issue is seen intermittently only when you restart code-server when an active connection is in place. There are no extra logs being displayed even when you’re in debug mode. My suspicion is that this could also be a long standing issue and not a regression (won’t know until we try).

Here’s how you can reproduce this (not consistently, but not super rare either):

  1. Start code-server like below
  2. Connect to the server using your browser and keep it open.
  3. Kill the code-server in the background. UI detects disconnect and attempts to reconnect (with a timer).
  4. Start code-server before the reconnect attempt by UI

and you’ll see this error and code-server won’t recover till you kill it.

WORKAROUND: Essentially if code-server crashes and recovers you’ll have to close your code-server browser window and restart it again in the background.

❯ docker run --rm -it -v "${HOME}/Downloads:/downloads" -p 8080:8080 ubuntu bash
root@900973700feb:/# dpkg -i /downloads/code-server_3.8.1_amd64.deb
Selecting previously unselected package code-server.
(Reading database ... 4121 files and directories currently installed.)
Preparing to unpack .../code-server_3.8.1_amd64.deb ...
Unpacking code-server (3.8.1) ...
Setting up code-server (3.8.1) ...
root@900973700feb:/# code-server --auth none --log debug --bind-addr 0.0.0.0:8080
[2021-02-15T05:36:36.170Z] info  Wrote default config file to ~/.config/code-server/config.yaml
[2021-02-15T05:36:36.495Z] info  code-server 3.8.1 41ad0c0c4c14df78e1bfa3a44d8b633ed2fc26e5
[2021-02-15T05:36:36.496Z] info  Using user-data-dir ~/.local/share/code-server
[2021-02-15T05:36:36.507Z] info  Using config file ~/.config/code-server/config.yaml
[2021-02-15T05:36:36.507Z] info  HTTP server listening on http://0.0.0.0:8080 
[2021-02-15T05:36:36.507Z] info    - Authentication is disabled 
[2021-02-15T05:36:36.507Z] info    - Not serving HTTPS 
[2021-02-15T05:36:50.896Z] debug forking vs code...
[2021-02-15T05:36:51.271Z] debug setting up vs code...
[2021-02-15T05:36:51.273Z] debug vscode got message from code-server {"type":"init"}
[2021-02-15T05:36:51.952Z] debug vscode got message from code-server {"type":"socket"}
[2021-02-15T05:36:51.959Z] debug vscode New connection {"token":"04517fb3-00f0-43f2-8e9a-d68e66b36e98"}
[2021-02-15T05:36:52.354Z] debug Making request {"uri":"https://api.github.com/repos/cdr/code-server/releases/latest"}
[2021-02-15T05:36:52.372Z] debug vscode got message from code-server {"type":"socket"}
[2021-02-15T05:36:52.464Z] debug vscode New connection {"token":"91f250e8-81a1-4ec1-b340-6457611f0370"}
[2021-02-15T05:36:52.868Z] debug got latest version {"latest":"3.9.0"}
[2021-02-15T05:36:52.868Z] debug comparing versions {"current":"3.8.1","latest":"3.9.0"}
^Croot@900973700feb:/# code-server --auth none --log debug --bind-addr 0.0.0.0:8080
[2021-02-15T05:37:05.916Z] info  code-server 3.8.1 41ad0c0c4c14df78e1bfa3a44d8b633ed2fc26e5
[2021-02-15T05:37:05.917Z] info  Using user-data-dir ~/.local/share/code-server
[2021-02-15T05:37:05.928Z] info  Using config file ~/.config/code-server/config.yaml
[2021-02-15T05:37:05.928Z] info  HTTP server listening on http://0.0.0.0:8080 
[2021-02-15T05:37:05.928Z] info    - Authentication is disabled 
[2021-02-15T05:37:05.928Z] info    - Not serving HTTPS 
[2021-02-15T05:37:09.141Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:37:09.152Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:37:09.419Z] debug forking vs code...
[2021-02-15T05:37:09.788Z] debug setting up vs code...
[2021-02-15T05:37:09.790Z] debug vscode got message from code-server {"type":"init"}
[2021-02-15T05:37:10.426Z] debug vscode got message from code-server {"type":"socket"}
[2021-02-15T05:37:10.436Z] debug vscode New connection {"token":"a259303c-c6ed-452c-b5ba-2bd9860b722d"}
[2021-02-15T05:37:10.691Z] debug got latest version {"latest":"3.9.0"}
[2021-02-15T05:37:10.692Z] debug comparing versions {"current":"3.8.1","latest":"3.9.0"}
[2021-02-15T05:37:10.704Z] debug vscode got message from code-server {"type":"socket"}
[2021-02-15T05:37:10.791Z] debug vscode New connection {"token":"7022997f-d0a4-474b-9cf2-ce39cab5d665"}
^Croot@900973700feb:/# code-server --auth none --log debug --bind-addr 0.0.0.0:8080
[2021-02-15T05:37:29.403Z] info  code-server 3.8.1 41ad0c0c4c14df78e1bfa3a44d8b633ed2fc26e5
[2021-02-15T05:37:29.404Z] info  Using user-data-dir ~/.local/share/code-server
[2021-02-15T05:37:29.416Z] info  Using config file ~/.config/code-server/config.yaml
[2021-02-15T05:37:29.416Z] info  HTTP server listening on http://0.0.0.0:8080 
[2021-02-15T05:37:29.416Z] info    - Authentication is disabled 
[2021-02-15T05:37:29.416Z] info    - Not serving HTTPS 
[2021-02-15T05:37:31.246Z] debug forking vs code...
[2021-02-15T05:37:31.636Z] debug setting up vs code...
[2021-02-15T05:37:31.637Z] debug vscode got message from code-server {"type":"init"}
[2021-02-15T05:37:32.029Z] debug vscode got message from code-server {"type":"socket"}
[2021-02-15T05:37:32.037Z] debug vscode New connection {"token":"8ec9a5ae-77a6-408b-932f-3f3d2ee1915a"}
[2021-02-15T05:37:32.315Z] debug got latest version {"latest":"3.9.0"}
[2021-02-15T05:37:32.315Z] debug comparing versions {"current":"3.8.1","latest":"3.9.0"}
[2021-02-15T05:37:32.327Z] debug vscode got message from code-server {"type":"socket"}
[2021-02-15T05:37:32.462Z] debug vscode New connection {"token":"0ebbaa01-458d-4ba8-80bf-9f7a1f2d8689"}
^Croot@900973700feb:/# code-server --auth none --log debug --bind-addr 0.0.0.0:8080
[2021-02-15T05:37:41.922Z] info  code-server 3.8.1 41ad0c0c4c14df78e1bfa3a44d8b633ed2fc26e5
[2021-02-15T05:37:41.923Z] info  Using user-data-dir ~/.local/share/code-server
[2021-02-15T05:37:41.935Z] info  Using config file ~/.config/code-server/config.yaml
[2021-02-15T05:37:41.935Z] info  HTTP server listening on http://0.0.0.0:8080 
[2021-02-15T05:37:41.935Z] info    - Authentication is disabled 
[2021-02-15T05:37:41.935Z] info    - Not serving HTTPS 
[2021-02-15T05:37:44.138Z] debug forking vs code...
[2021-02-15T05:37:44.523Z] debug setting up vs code...
[2021-02-15T05:37:44.524Z] debug vscode got message from code-server {"type":"init"}
[2021-02-15T05:37:44.851Z] debug vscode got message from code-server {"type":"socket"}
[2021-02-15T05:37:44.857Z] debug vscode New connection {"token":"e950ac7b-8b5c-49d7-8b75-e04032c4b5db"}
[2021-02-15T05:37:45.108Z] debug got latest version {"latest":"3.9.0"}
[2021-02-15T05:37:45.108Z] debug comparing versions {"current":"3.8.1","latest":"3.9.0"}
[2021-02-15T05:37:45.119Z] debug vscode got message from code-server {"type":"socket"}
[2021-02-15T05:37:45.237Z] debug vscode New connection {"token":"6c45170e-ab73-4593-aeee-c582199b2be0"}
^Croot@900973700feb:/# code-server --auth none --log debug --bind-addr 0.0.0.0:8080
[2021-02-15T05:37:56.833Z] info  code-server 3.8.1 41ad0c0c4c14df78e1bfa3a44d8b633ed2fc26e5
[2021-02-15T05:37:56.834Z] info  Using user-data-dir ~/.local/share/code-server
[2021-02-15T05:37:56.848Z] info  Using config file ~/.config/code-server/config.yaml
[2021-02-15T05:37:56.848Z] info  HTTP server listening on http://0.0.0.0:8080 
[2021-02-15T05:37:56.848Z] info    - Authentication is disabled 
[2021-02-15T05:37:56.848Z] info    - Not serving HTTPS 
[2021-02-15T05:37:59.150Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:37:59.161Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:38:17.104Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:38:19.165Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:38:29.672Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:38:39.202Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:38:49.675Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:38:59.263Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-02-15T05:39:09.689Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
    at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
    at step (/usr/lib/code-server/out/node/vscode.js:63:23)
    at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
    at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

It’s intermittent for me, and I can’t isolate when/why it happens.

remoteagent.log [2021-02-10 22:31:26.624] [remoteagent] [error] /home/inversion/.local/share/code-server/extensions {"errno":-2,"code":"ENOENT","syscall":"scandir","path":"/home/inversion/.local/share/code-server/extensions"}

exthost.log

[2021-02-10 22:31:29.982] [exthost] [info] ExtensionService#_doActivateExtension vscode.python {"startup":false,"extensionId":{"value":"vscode.python","_lower":"vscode.python"},"activationEvent":"onLanguage:python"}
[2021-02-10 22:31:29.982] [exthost] [info] ExtensionService#loadCommonJSModule file:///usr/lib/code-server/lib/vscode/extensions/python/dist/pythonMain
[2021-02-10 22:31:29.985] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch {"startup":true,"extensionId":{"value":"vscode.debug-auto-launch","_lower":"vscode.debug-auto-launch"},"activationEvent":"*"}
[2021-02-10 22:31:29.985] [exthost] [info] ExtensionService#loadCommonJSModule file:///usr/lib/code-server/lib/vscode/extensions/debug-auto-launch/dist/extension
[2021-02-10 22:31:29.987] [exthost] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"extensionId":{"value":"vscode.emmet","_lower":"vscode.emmet"},"activationEvent":"*"}
[2021-02-10 22:31:29.987] [exthost] [info] ExtensionService#loadCommonJSModule file:///usr/lib/code-server/lib/vscode/extensions/emmet/dist/node/emmetNodeMain
[2021-02-10 22:31:30.007] [exthost] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":"*"}
[2021-02-10 22:31:30.007] [exthost] [info] ExtensionService#loadCommonJSModule file:///usr/lib/code-server/lib/vscode/extensions/git/dist/main
[2021-02-10 22:31:30.039] [exthost] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"extensionId":{"value":"vscode.merge-conflict","_lower":"vscode.merge-conflict"},"activationEvent":"*"}
[2021-02-10 22:31:30.039] [exthost] [info] ExtensionService#loadCommonJSModule file:///usr/lib/code-server/lib/vscode/extensions/merge-conflict/dist/mergeConflictMain
[2021-02-10 22:31:30.042] [exthost] [info] ExtensionService#_doActivateExtension vscode.search-result {"startup":true,"extensionId":{"value":"vscode.search-result","_lower":"vscode.search-result"},"activationEvent":"*"}
[2021-02-10 22:31:30.042] [exthost] [info] ExtensionService#loadCommonJSModule file:///usr/lib/code-server/lib/vscode/extensions/search-result/dist/extension.js
[2021-02-10 22:31:30.202] [exthost] [info] ExtensionService#_doActivateExtension vscode.github {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":"*"}
[2021-02-10 22:31:30.202] [exthost] [info] ExtensionService#loadCommonJSModule file:///usr/lib/code-server/lib/vscode/extensions/github/dist/extension.js
[2021-02-10 22:31:30.306] [exthost] [info] eager extensions activated
[2021-02-10 22:31:30.391] [exthost] [warning] [Decorations] CAPPING events from decorations provider vscode.git 1244
[2021-02-10 22:31:30.405] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode.js-debug {"startup":false,"extensionId":{"value":"ms-vscode.js-debug","_lower":"ms-vscode.js-debug"},"activationEvent":"onCommand:extension.js-debug.clearAutoAttachVariables"}
[2021-02-10 22:31:30.405] [exthost] [info] ExtensionService#loadCommonJSModule file:///usr/lib/code-server/lib/vscode/extensions/ms-vscode.js-debug/src/extension.js

I appreciate everyone’s work here! 😃

I’m unable to reproduce this on a fresh install. Will be able to install 3.8.1 only over the weekend (I use code-server as my primary daily driver).

Here’s how I tried to reproduce it in an isolated environment (although, I failed to reproduce it):

# Download the code-server installer for ubuntu
$ docker run --rm -it -v "${HOME}/Downloads:/downloads" -p 8080:8080 ubuntu bash
# dpkg -i /downloads/code-server*.deb
# code-server --auth none --log debug --bind-addr 0.0.0.0:8080

Trying to connect on localhost:8080 is working fine for now.

Sorry, I have unsubscribed from this issue. I have updated the workaround in the first comment so that folks coming from searches get to know of it without scrolling to the bottom.

But I’m not sure if this is the same problem initially reported? Because 3.8.0 has the same behavior and downgrading is mentioned to work.

Also, yes @code-asher even I had suspected that same. Downgrading probably helped me by not crashing my code-server in the first place.

@jsjoeio, as @walterreade rightly pointed out, this issue is seen intermittently only when you restart code-server when an active connection is in place. There are no extra logs being displayed even when you’re in debug mode. My suspicion is that this could also be a long standing issue and not a regression (won’t know until we try).

But I’m not sure if this is the same problem initially reported? Because 3.8.0 has the same behavior and downgrading is mentioned to work.

Ohhh yeah VS Code is spawned when the page initially connects. Reconnection won’t spawn it again so a page refresh is required if the process restarts during an active connection.

It might make sense for us to spawn it on a reconnection anyway. The reconnection will then fail because there’s no longer any reconnection state on the server end but I think at that point at least VS Code will ask you to refresh rather than keep trying to reconnect.

@jsjoeio This was a fresh install on a new VM, with no extensions added. (And again the issue disappeared by downgrading to 3.8.0.

@zapstar When running the Container as root that should not happen. I fixed this issue by using USER root in the Dockerfile. But I dont use Code-server on docker. I use caprover reverse proxy to code-server on host

@kaaax0815 that could be the case as well, I was running the container as root.

I got this error in Docker when having Bad File Permissions

Ran into the same issue. Also resolved by downgrading to 3.8.0.

  • Web Browser: Chrome
  • Local OS: MacOS Catalina 10.15.7
  • Remote OS: Ubuntu Linux (5.4.0-1036-gcp #39-Ubuntu SMP Thu Jan 14 18:41:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux)
  • Remote Architecture: amd64

Can I enable debug or something like that could help you further. Looks like accessing vscode via browser is killing some process. If you can see it complains about error vscode is not running Error: vscode is not running.