Skip to content
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

Pre-existing host config blocks attaching to another #270

Closed
slagiewka opened this issue Nov 4, 2023 · 2 comments · Fixed by #276
Closed

Pre-existing host config blocks attaching to another #270

slagiewka opened this issue Nov 4, 2023 · 2 comments · Fixed by #276

Comments

@slagiewka
Copy link

Error running command tailscale.node.openRemoteCode: Cannot read properties of undefined (reading 'persistToSSHConfig'). This is likely caused by the extension that contributes tailscale.node.openRemoteCode.

Logs -> Extension host:

[error] TypeError: Cannot read properties of undefined (reading 'persistToSSHConfig')
	at /home/username/.vscode/extensions/tailscale.vscode-tailscale-1.0.0/dist/extension.js:2:326064
	at i.h (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:125:139669)
	at i.$executeContributedCommand (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:125:140529)
	at n.S (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:134:10836)
	at n.Q (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:134:10602)
	at n.M (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:134:9686)
	at n.L (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:134:8901)
	at h.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:134:7565)
	at c.y (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)
	at c.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:2119)
	at d.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:96:14047)
	at h.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:153:7918)
	at c.y (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)
	at c.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:2119)
	at d.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:96:14047)
	at MessagePortMain.<anonymous> (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:153:6198)
	at MessagePortMain.emit (node:events:513:28)
	at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367) tailscale.node.openRemoteCode {"value":"Tailscale.vscode-tailscale","_lower":"tailscale.vscode-tailscale"}

How to reproduce:

  1. Have two TS hosts
  2. Attach VSCode to one of the hosts
  3. Try attaching to the other host

What happens here:

  1. Attaching to one of them creates the config (~/.config/Code/User/globalStorage/tailscale.vscode-tailscale/config.json)
  2. The file has only one host:
{
  "hosts": {
    "hostname-one.tailnetname.ts.net": {
      "persistToSSHConfig": false
    }
  }
}
  1. configManager has only one host but doesn't guard against the other not being in the manager

if (addr && this.configManager.config.hosts?.[addr].persistToSSHConfig !== false) {

In this case, hosts contain only one key: hostname-one.tailnetname.ts.net. hostname-two is not there, so the config is undefined.

I have successfully made it working again by changing the line from:

        if (addr && this.configManager.config.hosts?.[addr].persistToSSHConfig !== false) {

to:

        if (addr && this.configManager.config.hosts?.[addr]?.persistToSSHConfig !== false) {

Caused by #233.

I'm not sending a PR since I'm not sure of the consequences here. It works, but it might not be the best option here.

tylersmalley added a commit that referenced this issue Nov 20, 2023
Closes #270

Signed-off-by: Tyler Smalley <tyler@tailscale.com>
tylersmalley added a commit that referenced this issue Nov 21, 2023
Closes #270

Signed-off-by: Tyler Smalley <tyler@tailscale.com>
@tylersmalley
Copy link
Contributor

Thanks @slagiewka for the thorough report! Your suggestion is correct, and it has been merged. I will be working towards a release this week.

@jonghwanhyeon
Copy link

Do you mind if I ask when the version with that patch will be released?

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

Successfully merging a pull request may close this issue.

3 participants