code-server: New 3.9.2 not work on iPadOS, Safari

OS/Web Information

  • Web Browser: iPad Safari
  • Local OS: iPadOS 14.4.1
  • Remote OS: Ubuntu Debian GNU/Linux 9.13 (stretch)
  • Remote Architecture: amd64
  • code-server --version: 3.9.2 109d2ce3247869eaeab67aa7e5423503ec9eb859

Steps to Reproduce

  1. Open safari, navigate to server url

Expected

  1. Show UI after login

Actual

  1. Just blank after login

Screenshot

Notes

Seems cause by permessage-deflate extension, maybe add a option via command line is better?

[Log] [Service Worker] registered (register.js, line 14)
[Error] WebSocket connection to 'wss://ide.dosk.win/?reconnectionToken=4ab75c9c-1248-4a08-80ec-491ff6d51b5e&reconnection=false&skipWebSocketFrames=false' failed: Received unexpected extension: permessage-deflate
[Log]   ERR – "[remote-connection][Management   ][4ab75…][initial][ide.dosk.win:80] socketFactory.connect() failed or timed out. Error:" (workbench.web.api.js, line 626)
[Log]   ERR (workbench.web.api.js, line 626)
Error: WebSocket close with status code 1006
[Log]   ERR – "[remote-connection] An error occurred in the very first connect attempt, it will be treated as a permanent error! Error:" (workbench.web.api.js, line 626)
[Log]   ERR – Error: WebSocket close with status code 1006 (workbench.web.api.js, line 626)
Error: WebSocket close with status code 1006
[Log]   ERR – Error: WebSocket close with status code 1006 (workbench.web.api.js, line 626)
Error: WebSocket close with status code 1006
[Log]  WARN – "Ignoring the error while validating workspace folder vscode-remote://ide.dosk.win/data00/home/chenfuchun/Public/Codes/native/aha …" (workbench.web.api.js, line 626)
"Ignoring the error while validating workspace folder vscode-remote://ide.dosk.win/data00/home/chenfuchun/Public/Codes/native/aha - WebSocket close with status code 1006"
[Warning] The web worker extension host is started without an iframe sandbox! (workbench.web.api.js, line 1713)
[Log]   ERR – "WebSocket close with status code 1006: M@https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode…" (workbench.web.api.js, line 626)
"WebSocket close with status code 1006: M@https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:631:2095297
https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:631:2097056"
[Log]   ERR (1) (workbench.web.api.js, line 626)
JSON Parse error: Unexpected identifier "undefined": parsegetCachedViewContainerLocations — workbench.web.api.js:2743:8418733Zt — workbench.web.api.js:2743:8410218_createInstance — workbench.web.api.js:622:1893008_createAndCacheServiceInstance — workbench.web.api.js:622:1894626_safeCreateAndCacheServiceInstance — workbench.web.api.js:622:1893823get — workbench.web.api.js:622:1892109initLayout — workbench.web.api.js:2408:7646399(anonymous function) — workbench.web.api.js:2408:7692599asyncFunctionResumeinvokeFunction — workbench.web.api.js:622:1891952startup — workbench.web.api.js:2408:7692454(anonymous function) — workbench.web.api.js:2408:7698254asyncFunctionResume[native code]promiseReactionJobWithoutPromisepromiseReactionJob
[Log]   ERR – "WebSocket close with status code 1006: M@https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode…" (workbench.web.api.js, line 626)
"WebSocket close with status code 1006: M@https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:631:2095297
https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:631:2097056"
[Log]   ERR (1) (workbench.web.api.js, line 626)
JSON Parse error: Unexpected identifier "undefined": parsegetCachedViewContainerLocations — workbench.web.api.js:2743:8418733Zt — workbench.web.api.js:2743:8410218_createInstance — workbench.web.api.js:622:1893008_createAndCacheServiceInstance — workbench.web.api.js:622:1894626_safeCreateAndCacheServiceInstance — workbench.web.api.js:622:1893823get — workbench.web.api.js:622:1892109(anonymous function) — workbench.web.api.js:2408:7698537invokeFunction — workbench.web.api.js:622:1891952asyncFunctionResume[native code]promiseReactionJobWithoutPromise
[Log]   ERR – "WebSocket close with status code 1006: M@https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode…" (workbench.web.api.js, line 626)
"WebSocket close with status code 1006: M@https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:631:2095297
https://ide.dosk.win/static/109d2ce3247869eaeab67aa7e5423503ec9eb859/usr/lib/code-server/lib/vscode/out/vs/workbench/workbench.web.api.js:631:2097056"

This issue can be reproduced in VS Code:No

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 35 (20 by maintainers)

Most upvoted comments

Update:

  1. Not work on safari macos 11.2.3 (20D91) either, with the same error
  2. Patch to work like this
sudo sed -i "s/req.headers\[\"sec-websocket-extensions\"\]/false/g" \
    /usr/lib/code-server/out/node/routes/vscode.js
sudo sed -i "s/responseHeaders.push(\"Sec-WebSocket-Extensions/\/\/responseHeaders.push(\"Sec-WebSocket-Extensions/g" \
    /usr/lib/code-server/out/node/routes/vscode.js

Oh no! Thank you @springhack for the detailed report and the patches.

And thank you @sh1luo for your extra notes as well!

We’ll see what we can do to fix this (and prevent it from happening again). cc @code-asher

Update:

  1. Not work on safari macos 11.2.3 (20D91) either, with the same error
  2. Patch to work like this
sudo sed -i "s/req.headers\[\"sec-websocket-extensions\"\]/false/g" \
    /usr/lib/code-server/out/node/routes/vscode.js
sudo sed -i "s/responseHeaders.push(\"Sec-WebSocket-Extensions/\/\/responseHeaders.push(\"Sec-WebSocket-Extensions/g" \
    /usr/lib/code-server/out/node/routes/vscode.js

Thank You , I had the same issue. code server v3.9.2 ipad prt 12.9 4thg os 14.4.2 safari & chrome It works for me now

Hello,

I know issue is closed but issues #3004 #3017 and #3014 are related with this one.

Basically regardless of middlewares (proxy, ingress, etc…) when user opens up code-server in browser, and if browser doesn’t properly support websocket zlib compression and/or negotiation it fails. (Websocket Error 1006 in Safari)

Just my 2 cents about what you guys can do about it:

  • People complain about “white page” problem. I don’t know how easy or hard but having a static “connecting to websocket” or something like that in the initial page will give people clue about where it got stuck
  • Some of the proxies may not support zlib/compression on the websocket level. Thus, adding these kind of RFC/standards improvements behind flag (opt-in or opt-out). So, any user can turn it off if it does not work for them.

@jsjoeio I can confirm this happens in Safari on macOS 11.

The root of the error seems to be:

ERR [remote-connection][ExtensionHost][47c0b…][initial][<hidden>:80] socketFactory.connect() failed or timed out. Error:
log.ts:296   ERR Error: WebSocket close with status code 1006
    at WebSocket.<anonymous> (browserSocketFactory.ts:129)

Anybody else confirm? Running Chrome 89.0.4389.90

Edit: Also broken with the same error in Firefox 87.0

using chrome on ipadOS gets the same error,just blank. But everything goes well on Android OS.

Version 3.9.3 work for me, iPadOS 14.4.2, install using deb package

I can confirm v3.9.3 works for me: IpadOS 14.4.2, microk8s v1.20.5, helm chart, Safari

@vendvahk thanks for the report! Are there any logs (code-server --log debug or browser logs) you can share?

$ code-server --log debug
[2021-04-03T11:50:01.756Z] info  code-server 3.9.2 109d2ce3247869eaeab67aa7e5423503ec9eb859
[2021-04-03T11:50:01.758Z] info  Using user-data-dir ~/.local/share/code-server
[2021-04-03T11:50:01.775Z] info  Using config file ~/.config/code-server/config.yaml
[2021-04-03T11:50:01.775Z] info  HTTP server listening on http://0.0.0.0:8080
[2021-04-03T11:50:01.775Z] info    - Authentication is enabled
[2021-04-03T11:50:01.775Z] info      - Using password from ~/.config/code-server/config.yaml
[2021-04-03T11:50:01.775Z] info    - Not serving HTTPS
[2021-04-03T11:50:20.592Z] debug redirecting from / to ./login                        # from iPad with iOS 13.6.1 with Safari
[2021-04-03T11:50:58.761Z] debug redirecting from / to ./login
[2021-04-03T11:51:04.353Z] debug no valid cookie doman {"host":"192.168.5.2"}
[2021-04-03T11:51:04.354Z] debug redirecting from /login to ./
[2021-04-03T11:51:04.391Z] debug forking vs code...
[2021-04-03T11:51:05.451Z] debug setting up vs code...
[2021-04-03T11:51:05.455Z] debug vscode got message from code-server {"type":"init"}  # pressing browser reload button
[2021-04-03T11:51:17.274Z] debug setting up vs code...
[2021-04-03T11:51:17.274Z] debug vscode got message from code-server {"type":"init"}
[2021-04-03T11:51:20.989Z] debug setting up vs code...
[2021-04-03T11:51:20.989Z] debug vscode got message from code-server {"type":"init"}
[2021-04-03T11:51:43.284Z] debug redirecting from / to ./login                        # from iPad with iOS 13.6.1 with Chrome
[2021-04-03T11:51:48.259Z] debug no valid cookie doman {"host":"192.168.5.2"}
[2021-04-03T11:51:48.259Z] debug redirecting from /login to ./
[2021-04-03T11:51:48.274Z] debug setting up vs code...
[2021-04-03T11:51:48.275Z] debug vscode got message from code-server {"type":"init"}
[2021-04-03T11:51:52.348Z] debug setting up vs code...
[2021-04-03T11:51:52.348Z] debug vscode got message from code-server {"type":"init"}
[2021-04-03T11:52:44.611Z] debug redirecting from / to ./login                        # from iPhone with iOS 14.4.2 with Safari
[2021-04-03T11:52:46.259Z] debug redirecting from / to ./login
[2021-04-03T11:52:53.292Z] debug no valid cookie doman {"host":"192.168.5.2"}
[2021-04-03T11:52:53.292Z] debug redirecting from /login to ./
[2021-04-03T11:52:53.316Z] debug setting up vs code...
[2021-04-03T11:52:53.317Z] debug vscode got message from code-server {"type":"init"}
[2021-04-03T11:52:53.797Z] debug vscode got message from code-server {"type":"socket"}
[2021-04-03T11:52:53.822Z] debug vscode New connection {"token":"3e27f774-3c5d-4b6d-80da-b594ce3d8c11"}
[2021-04-03T11:52:54.121Z] debug got latest version {"latest":"3.9.2"}
[2021-04-03T11:52:54.122Z] debug comparing versions {"current":"3.9.2","latest":"3.9.2"}
[2021-04-03T11:52:54.169Z] debug vscode got message from code-server {"type":"socket"}
[2021-04-03T11:52:54.258Z] debug vscode New connection {"token":"c35faa2f-580e-40fd-ade2-22db4fe97895"}

Edit 1: Chrome JS Console on iPad shows following:

http://192.168.5.2:8080/
LOG%c%s%c%c%s%c%c%s%c%c%o%c color: #3794ff;font-weight: bold; options color: inherit;font-weight: normal;   (Object) color: inherit;font-weight: normal;  :  color: inherit;font-weight: normal;  [object Object] color: inherit;font-weight: normal;
ERROR[Service Worker] navigator is undefined

Edit 2: I did some more investigation with Safari. Other than 404 messages as in #1640, only major diference is:

[Error] [Service Worker] navigator is undefined
	(anonymous function) (register.js:14:2165)
	f (register.js:1:473)
	(anonymous function) (register.js:1:773)
	Global Code (register.js:1:1024)

I think it’s easier for me to just update iOS to latest version.

@nodesocket

helm upgrade code-server --values code-server.yaml ./ --recreate-pods

Instead of recreating the pod; try restarting the s6 service after applying the patch and while still in the pod. I also assumed you did a ‘find’ on vscode.js, as the path was different to that of the patch on kubernetes in my case.

s6-svc -r /var/run/s6/services/code-server

Worked for me.

I also would like to leave a comment. That “sed” fix looks like to be fixing the issue for iOS 14+, but apparently not for iOS 13.

On my iPhone with iOS 14.4.2 - fix worked. On my iPad with iOS 13.6.1 - after login still white page.

helm upgrade code-server --values code-server.yaml ./ --recreate-pods

Re-deployed the pod, but still the same error.

Screen Shot 2021-03-29 at 5 34 42 PM

@jsjoeio I got a Bash shell into the Kubernetes pod running code-server:

kubectl exec -it code-server-6784d969bd-hldrf -- /bin/bash
  coder@code-server-6784d969bd-hldrf:~$

You want me to just try running:

sudo sed -i "s/req.headers\[\"sec-websocket-extensions\"\]/false/g" \
    /usr/lib/code-server/out/node/routes/vscode.js
sudo sed -i "s/responseHeaders.push(\"Sec-WebSocket-Extensions/\/\/responseHeaders.push(\"Sec-WebSocket-Extensions/g" \
    /usr/lib/code-server/out/node/routes/vscode.js

@jsjoeio was this only related to Safari? Because, I am seeing this running 3.9.2. in Kubernetes via the Docker container and using both Chrome and Firefox.

@sh1luo I had a similar issue. Used: find / -name vscode.js to find out my files were in a slightly different path. The patch worked for me after adjusting the path to the vscode.js file.

thank you.Using your method, after editing this file everything goes well on iOS.

Just upgraded to 3.9.2 running in Kubernetes via Helm on Chrome and seeing this.

browserSocketFactory.ts:162 WebSocket connection to 'wss://<hidden>/?reconnectionToken=2cb654bd-29f1-4132-b584-f156eb9a4df6&reconnection=false&skipWebSocketFrames=false' failed: 
create @ browserSocketFactory.ts:162
connect @ browserSocketFactory.ts:212
s @ remoteAgentConnection.ts:192
r @ remoteAgentConnection.ts:233
i @ remoteAgentConnection.ts:310
o @ remoteAgentConnection.ts:334
w @ remoteAgentConnection.ts:407
log.ts:296   ERR [remote-connection][Management   ][2cb65…][initial][<hidden>:80] socketFactory.connect() failed or timed out. Error:
log.ts:296   ERR Error: WebSocket close with status code 1006
    at WebSocket.<anonymous> (browserSocketFactory.ts:129)
log.ts:296   ERR [remote-connection] An error occurred in the very first connect attempt, it will be treated as a permanent error! Error:
log.ts:296   ERR Error: WebSocket close with status code 1006
    at WebSocket.<anonymous> (browserSocketFactory.ts:129)
log.ts:296   ERR Error: WebSocket close with status code 1006
    at WebSocket.<anonymous> (browserSocketFactory.ts:129)
log.ts:290  WARN Ignoring the error while validating workspace folder vscode-remote:/<hidden>/home/coder - WebSocket close with status code 1006
webWorkerExtensionHost.ts:125 The web worker extension host is started without an iframe sandbox!
start @ webWorkerExtensionHost.ts:125
Kn @ extensionHostManager.ts:67
_createInstance @ instantiationService.ts:110
createInstance @ instantiationService.ts:76
(anonymous) @ abstractExtensionService.ts:447
_startExtensionHosts @ abstractExtensionService.ts:446
_initialize @ abstractExtensionService.ts:411
(anonymous) @ extensionService.ts:74
Promise.then (async)
Xs @ extensionService.ts:74
_createInstance @ instantiationService.ts:110
_createServiceInstance @ instantiationService.ts:230
_createServiceInstanceWithOwner @ instantiationService.ts:219
_createAndCacheServiceInstance @ instantiationService.ts:208
_safeCreateAndCacheServiceInstance @ instantiationService.ts:151
_getOrCreateServiceInstance @ instantiationService.ts:135
get @ instantiationService.ts:54
initLayout @ layout.ts:255
(anonymous) @ workbench.ts:137
invokeFunction @ instantiationService.ts:61
startup @ workbench.ts:130
open @ web.main.ts:95
async function (async)
open @ web.main.ts:83
Se @ web.main.ts:359
g @ workbench.web.api.ts:498
(anonymous) @ workbench.ts:498
(anonymous) @ workbench.ts:505
r._invokeFactory @ loader.js:1114
r.complete @ loader.js:1124
r._onModuleComplete @ loader.js:1750
r._onModuleComplete @ loader.js:1762
r._resolve @ loader.js:1710
r.defineModule @ loader.js:1353
o @ loader.js:1638
v @ loader.js:2145
r._invokeFactory @ loader.js:1114
r.complete @ loader.js:1124
r._onModuleComplete @ loader.js:1750
r._onModuleComplete @ loader.js:1762
r._resolve @ loader.js:1710
r.defineModule @ loader.js:1353
p @ loader.js:1800
(anonymous) @ workbench.nls.js:7