codesandbox / codesandbox-client

An online IDE for rapid web development
https://codesandbox.io
Other
12.97k stars 2.26k forks source link

Can not attach sandbox via vs code #8348

Closed aliaksandrsen closed 4 months ago

aliaksandrsen commented 5 months ago

🐛 bug report

Preflight Checklist

Description of the problem

Can not attach sandbox via vs code (got error)

How has this issue affected you? What are you trying to accomplish?

To Reproduce

image

Link to sandbox: [link]() (optional)

image https://codesandbox.io/p/devbox/gcksgx?file=%2Fpackage.json

Your Environment

Software Name/Version
Сodesandbox
Browser chrome
Operating System macos
CompuIves commented 5 months ago

Hey! Thanks for this report, I'm investigating why it's happening.

CompuIves commented 5 months ago

Hmm, I'm not able to reproduce this error. Could you share the output log of CodeSandbox? You can get that inside VSCode by opening the Output tab (at the bottom) and selecting CodeSandbox in the dropdown after the error has occured.

aliaksandrsen commented 5 months ago

@CompuIves SSH connection: 167.235.8.252:39558 SSH proxy configuration changed to true CLI already exists at /Users/t800/.config/codesandbox/csb-cli Starting task: "Development"

Screenshot 2024-02-16 at 2 11 32 PM
CompuIves commented 5 months ago

Okay, this is really valuable. Thanks for sharing!

Could you go into VSCode settings, search for "CodeSandbox" and then change the settings to reflect this?

image

After changing those settings, could you restart VSCode and try again? I think that might fix it.

aliaksandrsen commented 5 months ago

No I can not

I am trying open https://codesandbox.io/p/devbox/85tsvt?file=%2Fpackage.json

image

May be I need remove some extensions!?

CompuIves commented 5 months ago

Hmm, could be, not 100% sure. Could you share the output of Remote - SSH as well? That one should give a more clear error on why it could not connect.

CompuIves commented 5 months ago

I believe that something is going wrong with the websocket connection, given that you can connect to the web editor, I wonder if something went wrong with the SSH configuration that we did to make the connection. Another check you can do is opening "Remote Explorer" in the sidebar, and checking if under "SSH" you see something like this:

image
CompuIves commented 5 months ago

In the meantime I'm creating a new build where Websocat is enabled by default :)

aliaksandrsen commented 5 months ago
image

Here

image
aliaksandrsen commented 5 months ago

`[14:27:57.841] > channel 2: open failed: connect failed: open failed [14:27:58.016] > channel 3: open failed: connect failed: open failed [14:27:58.083] > channel 2: open failed: connect failed: open failed [14:27:58.173] Opening exec server for ssh-remote+sandbox.85tsvt.csb [14:27:58.174] Opening exec server for ssh-remote+sandbox.85tsvt.csb [14:27:58.182] Initizing new exec server for ssh-remote+sandbox.85tsvt.csb [14:27:58.184] Using commit id "903b1e9d8990623e3d7da1df3d33db3e42d80eda" and quality "stable" for server [14:27:58.185] Install and start server if needed [14:27:58.194] Running script with connection command: ssh -T -D 63183 -o ConnectTimeout=15 'sandbox.85tsvt.csb' bash [14:27:58.925] > Warning: Permanently added '85tsvt-62534.csb.app' (ED25519) to the list of known hosts. [14:27:58.925] Got some output, clearing connection timeout [14:28:01.320] > 667f2b1be1da: running [14:28:01.344] > Found existing installation at /root/.vscode-server...

Starting VS Code CLI... "/root/.vscode-server/code-903b1e9d8990623e3d7da1df3d33db3e42d80eda" command-shell --cli-data-dir "/root/.vscode-server/cli" --on-port --parent-process-id 1949 &> "/root/.vscode-server/.cli.903b1e9d8990623e3d7da1df3d33db3e42d80eda.log" < /dev/null printenv: SUPERVISOR_GROUP_NAME=pitcher-agent FNM_ARCH=x64 SUPERVISOR_SERVER_URL=unix:///var/run/supervisord.sock HOSTNAME=z58qm5 NPM_CONFIG_CACHE=/root/.cache/npm CSB_SANDBOX_ID=z58qm5 FNM_NODE_DIST_MIRROR=https://nodejs.org/dist CSB_BASE_PREVIEW_HOST=csb.app YARN_VERSION=1.22.19 YARN_CACHE_FOLDER=/root/.cache/yarn PWD=/workspaces/workspace LOGNAME=pitcher-host PROJECT_GID=1001 PITCHER_API_BASE_URL=https://codesandbox.io/api PNPM_VERSION=7.1.0 HOME=/root FNM_COREPACK_ENABLED=false NVM_SYMLINK_CURRENT=true PITCHER_CLIENTS_WSS_PORT=82 CODESANDBOX_HOST=z58qm5-$PORT.csb.app CSB=true VSCODE_AGENT_FOLDER=/root/.vscode-server NVM_DIR=/usr/local/share/nvm PITCHER_WORKSPACE_PATH=/project/sandbox CSB_EXEC_ID=d1914db7-5135-4d4c-b5f0-305a617455a3 TERM=xterm-256color SHLVL=1 FNM_VERSION_FILE_STRATEGY=local LC_CTYPE=C.UTF-8 FNM_RESOLVE_ENGINES=false WATCHMAN_VERSION=2022.05.30.00 SUPERVISOR_PROCESS_NAME=pitcher-agent CSB_PITCHER_MANAGER_BASE_URL=http://10.43.0.254:8001 WORKSPACE_PATH=/project/sandbox ZSH_DISABLE_COMPFIX=true PATH=/usr/local/share/nvm/current/bin:/usr/local/share/npm-global/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NPM_CONFIG_STORE_DIR=/root/.cache/pnpm PERMISSION_WATCHER_VERSION=0.1.3 FNM_DIR=/usr/share/fnm NODE_VERSION=20.9.0 FNM_MULTISHELL_PATH=/project/home/pitcher-host/.local/state/fnm_multishells/1062_1707736550532 FNM_LOGLEVEL=info PITCHER_ENV=production PITCHER_BIN_PATH=/pitcher/pitcher.cjs OLDPWD=/project/sandbox SUPERVISORENABLED=1 =/usr/bin/printenv Removing old logfile at /root/.vscode-server/.cli.903b1e9d8990623e3d7da1df3d33db3e42d80eda.log Spawned remote CLI: 1969 [14:28:01.365] > Waiting for server log... [14:28:01.403] > 667f2b1be1da: start SSH_AUTH_SOCK==== DISPLAY==== [14:28:01.418] > listeningOn==127.0.0.1:41553== osReleaseId==debian== arch==x86_64== vscodeArch==x64== bitness==64== tmpDir==/tmp== platform==linux== unpackResult==== didLocalDownload==0== downloadTime==== installTime==== serverStartTime==61== execServerToken==11aa11a1-1111-11a1-11aa-aaaaa111aa11== 667f2b1be1da: end [14:28:01.418] Received install output: SSH_AUTH_SOCK==== DISPLAY==== listeningOn==127.0.0.1:41553== osReleaseId==debian== arch==x86_64== vscodeArch==x64== bitness==64== tmpDir==/tmp== platform==linux== unpackResult==== didLocalDownload==0== downloadTime==== installTime==== serverStartTime==61== execServerToken==11aa11a1-1111-11a1-11aa-aaaaa111aa11==

[14:28:01.418] Remote server is listening on port 41553 [14:28:01.418] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":41553},"osReleaseId":"debian","arch":"x86_64","sshAuthSock":"","display":"","tmpDir":"/tmp","platform":"linux","execServerToken":"11aa11a1-1111-11a1-11aa-aaaaa111aa11"},"serverStartTime":61,"installUnpackCode":""} [14:28:01.420] Starting forwarding server. local port 63244 -> socksPort 63183 -> remotePort 41553 [14:28:01.420] Forwarding server listening on port 63244 [14:28:01.421] Waiting for ssh tunnel to be ready [14:28:01.421] Tunneled port 41553 to local port 63244 [14:28:01.421] Resolved "ssh-remote+sandbox.85tsvt.csb" to "port 63244" [14:28:01.421] Resolving exec server at port 63244 [14:28:01.422] [Forwarding server port 63244] Got connection 0 [14:28:01.422] [Forwarding server port 63244] Got connection 1 [14:28:01.709] Exec server for ssh-remote+sandbox.85tsvt.csb created and cached [14:28:01.784] Verified and reusing cached exec server for ssh-remote+sandbox.85tsvt.csb`

aliaksandrsen commented 5 months ago
image

I can see myself on web interface

aliaksandrsen commented 5 months ago

A couple of minutes ago I installed vs code insiders and it works on my laptop. But my main vs does not work with codesandbox extension

CompuIves commented 5 months ago

This is incredible information @aliaksandrsen, thanks so much for sharing! I now think that the connection succeeds, but the folder (/workspaces/workspace) is not created, making me think you might not be connecting with the container. I'm going to ask a team-member to take a look with me.

CompuIves commented 5 months ago

It's interesting that VSCode Insiders works... Would you mind sharing your VSCode settings? I wonder if there's a configuration about default path or something that could influence this.

aliaksandrsen commented 5 months ago

just { "codesandbox.currentWorkspace": "165091a3-7c46-4ec7-930f-107016549c62", "codesandbox.sshProxy": false, "codesandbox.websocat": true, "remote.SSH.remotePlatform": { "sandbox.2k96rf.csb": "linux" } I disabled everything else

aliaksandrsen commented 5 months ago

Now it is working! I also disabled all unnecessary extensions I will check later what is real root cause @CompuIves thanks a lot

aliaksandrsen commented 5 months ago

@CompuIves I found real root cause, it is setting "remote.SSH.remoteServerListenOnSocket": true An intersting thing - after first connection with such setting my devcontainer (devbox) become broken and I need to create another one.

CompuIves commented 4 months ago

Thanks for this information! I'll make sure that we have a warning for that case.