Skip to content

Offline localhost support? #1925

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hgarrereyn opened this issue Jul 29, 2020 · 8 comments
Closed

Offline localhost support? #1925

hgarrereyn opened this issue Jul 29, 2020 · 8 comments
Milestone

Comments

@hgarrereyn
Copy link

  • Web Browser: Chrome
  • Local OS: Chrome OS
  • Remote OS: Linux
  • Remote Architecture: amd64
  • code-server --version: 3.4.1

I've been trying to use code-server to develop locally on Chrome OS. I have a linux container running code-server and I can connect to it at localhost:8080.

For some reason, this requires internet access. My wifi is somewhat spotty and I get frequent "Reconnecting..." popups every 30 seconds or so. If I disable wifi, I just see the message "OFFLINE."

I understand that installing extensions requires internet access, but internet access should not be a dependency for a local connection.

I've seen #808 and unfortunately this no longer works on recent versions of code-server (seems to be 3.0.0+).

So I have two main questions:

  • Is there a way to disable the internet dependency for offline work?
  • Why does the heartbeat check require internet access? i.e. why do I see "Reconnecting..." popups while connected to localhost?
@code-asher
Copy link
Member

code-asher commented Jul 29, 2020

We have a service worker that returns OFFLINE if navigator.onLine is false. I didn't realize it would return false for local addresses though! Since just returning OFFLINE isn't any more helpful than the default browser error page (arguably less helpful actually) I think we should just remove that check entirely.

In the meantime if you're looking for an immediate workaround you could edit out/browser/serviceWorker.js and remove the block that checks navigator.onLine.

As for the "reconnecting" message though, that should only happen when the web sockets actually disconnect. Usually when they disconnect at regular intervals it means VS Code is crashing. Could you check code-server's output and see if there are any error messages? VS Code might also have some details logged in ~/.local/share/code-server/logs/[date] and there could also be errors in the browser console.

@hgarrereyn
Copy link
Author

After running in verbose mode, I see a stream of the following messages:

warn  discarding socket connection: not authenticated
debug vscode got message from code-server {"message":{"type":"socket","query":{"type":"Management","reconnectionToken":"84b0f0e4-7ba5-4f15-bc35-7ffbd160cbf4","reconnection":"true","skipWebSocketFrames":"false"}}}
debug vscode got message from code-server {"message":{"type":"socket","query":{"type":"ExtensionHost","reconnectionToken":"b0be181d-54a3-493e-a021-bd0c1e9c5cd5","reconnection":"true","skipWebSocketFrames":"false"}}}

Specifically, the server prints the warn message and then a few seconds later the client realizes it has disconnected and reconnects. This happens when running with password authentication.

I tried disabling password authentication with --auth none and I no longer see the warn messages, however the client still disconnects and reconnects at regular intervals.

Looking at the server logs and browser logs, I don't see anything strange. The browser logs the handshake process and commands and occasionally an error. However the error seems unrelated. Nothing is printed right before the client reconnects. If I just sit idle, it disconnects about every 25 seconds and the only browser log is the handshake.

@code-asher
Copy link
Member

code-asher commented Aug 13, 2020

Ah I'm sorry I let this slip by me. Were you able to get any logs from ~/.local/share/code-server/logs/[date]?

@code-asher
Copy link
Member

code-asher commented Aug 13, 2020

I should clarify what I mean, you said you looked at the server logs and I wanted to check that you meant the ones from that directory and not just the code-server output, if that makes sense (VS Code outputs its own logs separately).

@code-asher
Copy link
Member

I'll also test this tomorrow in completely offline mode to make sure it's not something related to that.

@code-asher
Copy link
Member

Won't be able to test this until next week unfortunately, but it's still on my radar.

@code-asher
Copy link
Member

I tested out 3.4.1 (running in a local Linux container) after disabling my network. Interestingly enough navigator.onLine still returns true for me (Chrome) and I'm not experiencing any disconnections. 🤔

code-asher added a commit that referenced this issue Aug 26, 2020
We need the handler to be recognized as a PWA but we can just let the
original offline browser message show instead of our own message.

See #1925 and #1979.
code-asher added a commit that referenced this issue Aug 27, 2020
We need the handler to be recognized as a PWA but we can just let the
original offline browser message show instead of our own message.

See #1925 and #1979.
@nhooyr nhooyr added this to the v3.5.0 milestone Aug 31, 2020
@nhooyr
Copy link
Contributor

nhooyr commented Aug 31, 2020

v3.5.0 with VS Code v1.48.2 has been released, fixing this issue! 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants