microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.67k stars 291 forks source link

DevVolumes "Cannot read property 'cliHost' of undefined" when removing unused volumes #4966

Closed bamurtaugh closed 3 years ago

bamurtaugh commented 3 years ago

Testing #4952

Delete all stopped containers using the Docker extension Return to the Remote Explorer DevVolumes view, choose "Remove Unused Volumes…" While it works (unused volumes are removed and I get the welcome in the viewlet), I also get the following notification:

image

egamma commented 3 years ago

I cannot reproduce the error. @chrmarti do you have any ideas when the cliHostproperty of the dockerParameters is undefined? This is the call that triggers the error https://github.com/microsoft/vscode-remote-containers/blob/23ca5dc6d945ca0c24c4a3449a5ea31dd1cfad14/src/extension/explorer.ts#L446-L446

egamma commented 3 years ago

@bamurtaugh are you running remote containers in WSL? Can you always reproduce this behaviour? If yes, can you reproduce it when running on remote containers directly on Windows?

chrmarti commented 3 years ago

I don't see how this can happen from looking at the code. A stacktrace would help, could you check the dev console next time this happens?

bamurtaugh commented 3 years ago

I just tried the same two steps above:

Delete all stopped containers using the Docker extension Return to the Remote Explorer DevVolumes view, choose "Remove Unused Volumes…"

And encountered the same behavior:

image

@egamma I am not running Remote-Containers in WSL or have any containers open when I experience this. I just have VS Code open and running on the Windows side. Do I need to be working in a dev container to use the Remote Explorer to use "Remove Unused Volumes…"?

@chrmarti Here are my extension host logs:

[2021-05-03 09:53:03.865] [exthost] [info] extension host started [2021-05-03 09:53:03.906] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-containers {"startup":false,"extensionId":{"value":"ms-vscode-remote.remote-containers","_lower":"ms-vscode-remote.remote-containers"},"activationEvent":"onResolveRemoteAuthority:dev-container"} [2021-05-03 09:53:03.906] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.174.0/dist/extension/extension [2021-05-03 09:53:06.864] [exthost] [info] extension host terminating: received terminate message from renderer [2021-05-03 09:53:07.869] [exthost] [info] exiting with code 0 [2021-05-03 09:53:08.999] [exthost] [info] extension host started [2021-05-03 09:53:09.049] [exthost] [info] ExtensionService#_doActivateExtension vscode.microsoft-authentication {"startup":false,"extensionId":{"value":"vscode.microsoft-authentication","_lower":"vscode.microsoft-authentication"},"activationEvent":"onAuthenticationRequest:microsoft"} [2021-05-03 09:53:09.049] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/microsoft-authentication/dist/extension.js [2021-05-03 09:53:09.061] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch {"startup":true,"extensionId":{"value":"vscode.debug-auto-launch","_lower":"vscode.debug-auto-launch"},"activationEvent":""} [2021-05-03 09:53:09.061] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/debug-auto-launch/dist/extension [2021-05-03 09:53:09.067] [exthost] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":""} [2021-05-03 09:53:09.067] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/git/dist/main [2021-05-03 09:53:09.085] [exthost] [info] ExtensionService#_doActivateExtension GitHub.codespaces {"startup":true,"extensionId":{"value":"GitHub.codespaces","_lower":"github.codespaces"},"activationEvent":""} [2021-05-03 09:53:09.085] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/.vscode-insiders/extensions/github.codespaces-0.9.4/out/bundle/extension-bundle.js [2021-05-03 09:53:09.901] [exthost] [info] ExtensionService#_doActivateExtension GitHub.vscode-pull-request-github-insiders {"startup":true,"extensionId":{"value":"GitHub.vscode-pull-request-github-insiders","_lower":"github.vscode-pull-request-github-insiders"},"activationEvent":""} [2021-05-03 09:53:09.901] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/.vscode-insiders/extensions/github.vscode-pull-request-github-insiders-2021.5.3423/dist/extension [2021-05-03 09:53:10.065] [exthost] [info] ExtensionService#_doActivateExtension zhuangtongfa.material-theme {"startup":true,"extensionId":{"value":"zhuangtongfa.material-theme","_lower":"zhuangtongfa.material-theme"},"activationEvent":""} [2021-05-03 09:53:10.065] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/.vscode-insiders/extensions/zhuangtongfa.material-theme-3.10.13/out/extension.js [2021-05-03 09:53:10.452] [exthost] [info] ExtensionService#_doActivateExtension vscode.github-authentication {"startup":false,"extensionId":{"value":"GitHub.codespaces","_lower":"github.codespaces"},"activationEvent":"api"} [2021-05-03 09:53:10.452] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/github-authentication/dist/extension.js [2021-05-03 09:53:10.502] [exthost] [info] ExtensionService#_doActivateExtension ms-azuretools.vscode-docker {"startup":false,"extensionId":{"value":"ms-azuretools.vscode-docker","_lower":"ms-azuretools.vscode-docker"},"activationEvent":"onView:dockerContainers"} [2021-05-03 09:53:10.502] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/.vscode-insiders/extensions/ms-azuretools.vscode-docker-1.12.1/main [2021-05-03 09:53:10.829] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode.js-debug {"startup":false,"extensionId":{"value":"ms-vscode.js-debug","_lower":"ms-vscode.js-debug"},"activationEvent":"onCommand:extension.js-debug.clearAutoAttachVariables"} [2021-05-03 09:53:10.829] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/ms-vscode.js-debug/src/extension.js [2021-05-03 09:53:11.902] [exthost] [info] ExtensionService#_doActivateExtension vscode.configuration-editing {"startup":false,"extensionId":{"value":"vscode.configuration-editing","_lower":"vscode.configuration-editing"},"activationEvent":"onLanguage:jsonc"} [2021-05-03 09:53:11.902] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/configuration-editing/dist/configurationEditingMain [2021-05-03 09:53:11.909] [exthost] [info] ExtensionService#_doActivateExtension vscode.json-language-features {"startup":false,"extensionId":{"value":"vscode.json-language-features","_lower":"vscode.json-language-features"},"activationEvent":"onLanguage:jsonc"} [2021-05-03 09:53:11.909] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/json-language-features/client/dist/node/jsonClientMain [2021-05-03 09:53:11.926] [exthost] [info] ExtensionService#_doActivateExtension vscode.typescript-language-features {"startup":false,"extensionId":{"value":"vscode.typescript-language-features","_lower":"vscode.typescript-language-features"},"activationEvent":"onLanguage:jsonc"} [2021-05-03 09:53:11.926] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/typescript-language-features/dist/extension [2021-05-03 09:53:11.981] [exthost] [info] ExtensionService#_doActivateExtension vscode.github {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":""} [2021-05-03 09:53:11.981] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/github/dist/extension.js [2021-05-03 09:53:11.992] [exthost] [info] eager extensions activated [2021-05-03 09:53:12.004] [exthost] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":false,"extensionId":{"value":"vscode.emmet","_lower":"vscode.emmet"},"activationEvent":"onStartupFinished"} [2021-05-03 09:53:12.004] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/emmet/dist/node/emmetNodeMain [2021-05-03 09:53:12.012] [exthost] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":false,"extensionId":{"value":"vscode.merge-conflict","_lower":"vscode.merge-conflict"},"activationEvent":"onStartupFinished"} [2021-05-03 09:53:12.012] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/merge-conflict/dist/mergeConflictMain [2021-05-03 09:53:12.017] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-wsl-recommender {"startup":false,"extensionId":{"value":"ms-vscode-remote.remote-wsl-recommender","_lower":"ms-vscode-remote.remote-wsl-recommender"},"activationEvent":"onStartupFinished"} [2021-05-03 09:53:12.017] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/ms-vscode-remote.remote-wsl-recommender/dist/extension.js [2021-05-03 09:53:12.026] [exthost] [info] ExtensionService#_doActivateExtension vscode.testing-editor-contributions {"startup":false,"extensionId":{"value":"vscode.testing-editor-contributions","_lower":"vscode.testing-editor-contributions"},"activationEvent":"onStartupFinished"} [2021-05-03 09:53:12.026] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/extensions/testing-editor-contributions/dist/extension.js [2021-05-03 09:53:12.029] [exthost] [info] ExtensionService#_doActivateExtension dbaeumer.vscode-eslint {"startup":false,"extensionId":{"value":"dbaeumer.vscode-eslint","_lower":"dbaeumer.vscode-eslint"},"activationEvent":"onStartupFinished"} [2021-05-03 09:53:12.029] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/.vscode-insiders/extensions/dbaeumer.vscode-eslint-2.1.20/client/out/extension [2021-05-03 09:53:12.140] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-containers {"startup":false,"extensionId":{"value":"ms-vscode-remote.remote-containers","_lower":"ms-vscode-remote.remote-containers"},"activationEvent":"onStartupFinished"} [2021-05-03 09:53:12.140] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.174.0/dist/extension/extension [2021-05-03 09:53:12.177] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-wsl {"startup":false,"extensionId":{"value":"ms-vscode-remote.remote-wsl","_lower":"ms-vscode-remote.remote-wsl"},"activationEvent":"onStartupFinished"} [2021-05-03 09:53:12.177] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/brmurtau/.vscode-insiders/extensions/ms-vscode-remote.remote-wsl-0.56.1/dist/extension

In case it's interesting at all, here's the single line of output from the Docker output channel:

The Docker extension will try to connect to 'npipe:////./pipe/docker_engine', via context 'default'.

Let me know if any other info, logs, or troubleshooting would be helpful.

egamma commented 3 years ago

Do I need to be working in a dev container to use the Remote Explorer to use "Remove Unused Volumes…"?

No it should work in both setups and I just tried the setup where I'm not working in a dev container.

Can you reduce the test case to a single container:

If you can reproduce it in this setup,then can you please add the console log from the developer tools.

bamurtaugh commented 3 years ago

I just tried the flow with a single container:

image

And I didn't receive the error.

Out of curiosity (i.e. would I no longer receive the error), I cloned repos into two new volumes, removed the stopped containers with the Docker extension, and then removed unused volumes from the remote explorer DevVolumes section.

image

So this behavior only seems to occur when I'm dealing with more than one container.

When looking through the Help -> Toggle Developer Tools -> Console output, here's an error stack track I found if it's helpful:

TypeError: Cannot read property 'cliHost' of undefined at LM.getWorkspaceFolderFromHostPath (c:\Users\brmurtau.vscode-insiders\extensions\ms-vscode-remote.remote-containers-0.174.0\dist\extension\extension.js:278:15173) at LM.trySetEntryWithDevAuthority (c:\Users\brmurtau.vscode-insiders\extensions\ms-vscode-remote.remote-containers-0.174.0\dist\extension\extension.js:278:16063) at LM.trySetEntry (c:\Users\brmurtau.vscode-insiders\extensions\ms-vscode-remote.remote-containers-0.174.0\dist\extension\extension.js:278:17224) at LM.setRecentEntries (c:\Users\brmurtau.vscode-insiders\extensions\ms-vscode-remote.remote-containers-0.174.0\dist\extension\extension.js:278:17626) at processTicksAndRejections (internal/process/task_queues.js:93:5) at LM.setContainerTypes (c:\Users\brmurtau.vscode-insiders\extensions\ms-vscode-remote.remote-containers-0.174.0\dist\extension\extension.js:278:14434) at LM.getChildGroups (c:\Users\brmurtau.vscode-insiders\extensions\ms-vscode-remote.remote-containers-0.174.0\dist\extension\extension.js:278:11484) at d.fetchChildrenNodes (c:\Users\brmurtau\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:87:60999) onDidChangeNotification @ notificationsAlerts.ts:38

chrmarti commented 3 years ago

getWorkspaceFolderFromHostPath() probably accesses this.dockerParams after it was cleared by refresh(). I think getChildren() is only called once at a time by the extension host, but the extension can still call refresh() concurrently itself. It might make sense to pass this.dockerParams as a parameter starting in getChildren() to avoid this.

egamma commented 3 years ago

Adding @alexr00 from the above stack trace it looks like the exception occurs in the TargetsTree. What I don't understand is that pruning the volumes results in a prune event, but the TargetsTree does not register for prune events.

An alternate fix would be to protect against an undefined cliHost here.

chrmarti commented 3 years ago

Looks like I introduced that a while back (only now checked), I'll take a look.

chrmarti commented 3 years ago

One way to reproduce this is to rapidly click on the Refresh action in the Remote Explorer.

bamurtaugh commented 3 years ago

Marking as verified as I'm now able to perform the same two steps:

And I no longer receive the error message:

image