You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
heartbeat file modify date keeps getting updated #2112
the heartbeat file modify date seems acting a bit weird.
if you open the code server and then close the code server in a relatively short time window, and then ssh into the vm machine to check out the heartbeat file modify date, you will start noticing that the heartbeat file modify date keeps getting updated every minute, but there is no active browser connection to code server.
If you run code-server with --log trace it will report how many connections it thinks are still connected. Could you do that and verify that it reports > 0 when no browser windows are open?
Odd, there should definitely be stdout. We also log stdout to ~/.local/share/code-server/coder-logs so you could check that.
I ran 3.5.0 but wasn't able to replicate the issue (Firefox & Chrome running locally on Linux):
# < connected here
[2020-09-28T22:18:24.774Z] trace 2 active connections
[2020-09-28T22:18:24.775Z] trace heartbeat
[server] received ping {"proxies":3}
[server] received ping {"proxies":3}
[2020-09-28T22:19:24.780Z] trace 2 active connections
[2020-09-28T22:19:24.780Z] trace heartbeat
[server] received ping {"proxies":3}
# < disconnected here
[server] disconnected from client {"proxies":3}
[2020-09-28T22:20:24.785Z] trace 0 active connections
# < notice no "trace heartbeat" line
I also double-checked the heartbeat file and the timestamp was at 22:19 which matches with the last heartbeat log.
Hi @code-asher
it's kinda sporadic.
but the issue still exists for sure.
when all browsers closed, it seems still one active connection, and then I open one session it says 2 active connections.
and then I close the browser again, it turn back to 0.
PFA
Ah, there will be two connections per page since VS Code makes two
websocket connections. So with that in mind it looks like things are
working as expected, at least as far as these logs go.
Hi @code-asher
so I see what you meant, and after a few times retry, I reproduced again. and this logs seems a bit different from previous ones.
what happened was, when I created a new instance and opened vscode it asks me to reload window because it tries to reconnect. and then I did click reload window and then everything back to normal, after a few minutes, I turned off browser tab, and never opened the vscode link again.
Ah yeah it definitely looks like some connection isn't closing.
I tried to replicate on 3.5.0 but I'm not having much luck. Here's what
I did based on your comment, do these look like the right steps?
1. Start code-server
2. Open code-server in the browser
3. Restart code-server
4. Click "reconnect now" or wait for VS Code to reconnect, it will fail
5. Click "reload window"
6. Once VS Code has connected, close the VS Code tab
Once I do these steps I get this for the next heartbeat:
```
[2020-10-16T15:48:13.213Z] trace 0 active connections
```
I tried it a few times but no luck yet.
It's also interesting that you get four connections at one point! Very
strange.
Do you know if this happens if you close your browser entirely?
so I just closed the whole browser chrome entirely, and after that, when I check the log, it's still updating every minute.
I guess to reproduce, you have to have a new VM instance and then put the link in a iframe to open it when VM instance code server is ready.
I noticed that for any code server vscode that had this issue and then If I open the vscode again, it will most likely update the connections to its correct amount and then if you close the browser tab, the connection will back to 0.
Hmm that's very interesting. I'll try an iframe and maybe I can spin up
some VMs to test as well. I think what I'll do in the meantime is add
some more detailed logging which will hopefully help figure out what
connection isn't getting closed.
@code-asher
sounds good, also, I can give you access to the VM machine which has the 1 active connection issue if you give me your public key if that helps. my email is oweng@filtered.ai.
This issue happens to me all the time. I'm using a chromebook to connect. There's a proxy between vs code and the chromebook, but that probably doesn't matter. The logs show:
code-server[17244]: [2021-04-04T15:44:58.008Z] trace heartbeat
code-server[17244]: [2021-04-04T15:45:58.010Z] trace 1 active connection
code-server[17244]: [2021-04-04T15:45:58.010Z] trace heartbeat
code-server[17244]: [2021-04-04T15:46:58.013Z] trace 1 active connection
There are definitely no open connections left when this is happening:
netstat -apunt | grep 8443
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 17297/node
The local nodejs version is:
nodejs --version
v10.24.0
Code-server seems to have its own node version though:
This seems to happen very reliably when the chromebook fails asleep, so I suspect that nodejs is struggling with detecting when the connection goes away.
vs code is being started by systemd, in case that's relevant
Sorry, this turned out to be a pretty time consuming exercise. I don't think I'll be able to come up with a better repro easily. I tried disconnecting the network, but that didn't seem to work. I'm not sure exactly what happens at the network level when a chromebooks falls asleep.
I've seen this occasionally as well but I'm not sure what exactly reproduces it. I think we should still try to add some more logging around what connections exactly are open to help figure it out.
When I patched the output file lib/vscode/out/vs/server/entry.js, place a console.log(1234), before all this._onMessage.fire call (I think the source code contained within lib/vscode/src/vs/base/parts/ipc/common/ipc.net.ts)
When no open Browser Tabs:
There's no1234 output, but only 1 active connection.
When opened a Browser Tab for code-server:
There're many 1234 output, together with other normal logs.
Maybe we can add some check for the real onMessage fired? If no message, no heartbeat?
We could change the heartbeat mechanism to use onMessage or something
like that but I think that might disguise the problem that there is some
connection hanging open.
Currently we use `getConnections` on the server
(https://nodejs.org/api/net.html#net_server_getconnections_callback)
Since this returns >= 1 I think it means there is a connection failing
to close and we need to make sure it closes properly somehow.
I encountered this problem, too.
Once I've visited code-server and left, no matter what I do (close tab, even close chrome), there will always be 1 active connection.
lsof and ss shows there is no IPv4 connections related to any code-server processes
Activity
code-asher commentedon Sep 18, 2020
If you run
code-serverwith--log traceit will report how many connections it thinks are still connected. Could you do that and verify that it reports > 0 when no browser windows are open?I'll try to replicate as well as soon as I can.
Oliver-Weng-Sorcerer commentedon Sep 18, 2020
my service starts with systemctl start code-server@$USER,
I modified the code-server.service file to include
--log tracelocated at /usr/lib/systemd/system/user/and restarted the systemctl , it seems still don't see any relevant log shows up when I do
journalctl -u code-serverI do see some extension logs located at .../.local/share/code-server/logs/...
Oliver-Weng-Sorcerer commentedon Sep 21, 2020
Hi @code-asher
I'm wondering if you can reproduce the same issue ?
code-asher commentedon Sep 28, 2020
Odd, there should definitely be stdout. We also log stdout to
~/.local/share/code-server/coder-logsso you could check that.I ran 3.5.0 but wasn't able to replicate the issue (Firefox & Chrome running locally on Linux):
I also double-checked the heartbeat file and the timestamp was at 22:19 which matches with the last heartbeat log.
Oliver-Weng-Sorcerer commentedon Oct 14, 2020
Hi @code-asher
it's kinda sporadic.
but the issue still exists for sure.
when all browsers closed, it seems still one active connection, and then I open one session it says 2 active connections.
and then I close the browser again, it turn back to 0.
PFA
Thanks,
any ideas in terms of what's going on ?
Oliver-Weng-Sorcerer commentedon Oct 14, 2020
reproduced again.
PFA for the image to get some more insights.
Thanks
code-asher commentedon Oct 14, 2020
Oliver-Weng-Sorcerer commentedon Oct 16, 2020
Hi @code-asher
so I see what you meant, and after a few times retry, I reproduced again. and this logs seems a bit different from previous ones.
what happened was, when I created a new instance and opened vscode it asks me to reload window because it tries to reconnect. and then I did click reload window and then everything back to normal, after a few minutes, I turned off browser tab, and never opened the vscode link again.
PFA for the log.
Thanks
-Oliver
code-asher commentedon Oct 16, 2020
Oliver-Weng-Sorcerer commentedon Oct 16, 2020
Hi @code-asher
so I just closed the whole browser chrome entirely, and after that, when I check the log, it's still updating every minute.
I guess to reproduce, you have to have a new VM instance and then put the link in a iframe to open it when VM instance code server is ready.
I noticed that for any code server vscode that had this issue and then If I open the vscode again, it will most likely update the connections to its correct amount and then if you close the browser tab, the connection will back to 0.
code-asher commentedon Oct 16, 2020
Oliver-Weng-Sorcerer commentedon Oct 16, 2020
@code-asher
sounds good, also, I can give you access to the VM machine which has the 1 active connection issue if you give me your public key if that helps. my email is oweng@filtered.ai.
Thanks
24 remaining items
vikstrous2 commentedon Apr 4, 2021
This issue happens to me all the time. I'm using a chromebook to connect. There's a proxy between vs code and the chromebook, but that probably doesn't matter. The logs show:
There are definitely no open connections left when this is happening:
The local nodejs version is:
Code-server seems to have its own node version though:
This seems to happen very reliably when the chromebook fails asleep, so I suspect that nodejs is struggling with detecting when the connection goes away.
vs code is being started by systemd, in case that's relevant
lsof doesn't show anything interesting:
Starting and stopping the vs code client (browser tab) does fix the issue and the code-server logs go back to:
After the "fix", lsof and netstat show the same thing as before.
jsjoeio commentedon Apr 5, 2021
Do you mind opening up a separate issue and filing a bug report with reproduction steps? We can take a closer look and hopefully find a fix.
vikstrous2 commentedon Apr 7, 2021
Ok. I'll try to narrow it down better first and come up with a repro that doesn't involve waiting for a chromebook to fall asleep :)
vikstrous2 commentedon Apr 9, 2021
Sorry, this turned out to be a pretty time consuming exercise. I don't think I'll be able to come up with a better repro easily. I tried disconnecting the network, but that didn't seem to work. I'm not sure exactly what happens at the network level when a chromebooks falls asleep.
code-asher commentedon Apr 12, 2021
I've seen this occasionally as well but I'm not sure what exactly reproduces it. I think we should still try to add some more logging around what connections exactly are open to help figure it out.
jsjoeio commentedon Apr 12, 2021
No worries at all. Thanks for trying @vikstrous2.
Added to On Deck. We can at least try to reproduce ourselves again and then also add logging like code-asher said.
futurist commentedon Jul 9, 2021
I've encountered the same issue, after several try, and found below logs possible related:
Above can be reproduced as below steps:
ENV: macOS15 + Code-Server:3.10.2 + Chrome91
Shift+Cmd+T(Reopen Last Closed Tab)And the logs will be appended
1 active connectionconstantly forever, even there's no open Browser Tabs.Hope it's helperful!
futurist commentedon Jul 9, 2021
When I patched the output file
lib/vscode/out/vs/server/entry.js, place aconsole.log(1234),before allthis._onMessage.firecall (I think the source code contained withinlib/vscode/src/vs/base/parts/ipc/common/ipc.net.ts)When no open Browser Tabs:
There's no
1234output, but only1 active connection.When opened a Browser Tab for code-server:
There're many
1234output, together with other normal logs.Maybe we can add some check for the real onMessage fired? If no message, no heartbeat?
jsjoeio commentedon Jul 9, 2021
Fantastic notes @futurist 👏
Maybe you're right. @code-asher is more familiar with the heartbeat file so I'll let him weigh in on it when he is back next week.
code-asher commentedon Jul 12, 2021
ifduyue commentedon Jul 21, 2021
I encountered this problem, too.
Once I've visited code-server and left, no matter what I do (close tab, even close chrome), there will always be 1 active connection.
lsof and ss shows there is no IPv4 connections related to any code-server processes
stale commentedon Jan 17, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days.