Honor default Docker context for WSL 2#1290
Conversation
| addDockerSettingsToEnv(process.env, oldEnv); | ||
| ext.dockerodeInitError = undefined; | ||
| ext.dockerode = new Dockerode(); | ||
| ext.dockerode = new Dockerode(process.env.DOCKER_HOST ? undefined : tryGetDefaultDockerContext()); |
There was a problem hiding this comment.
tryGetDefaultDockerContext cannot be async. VSCode does not appear to await activation of the extension; as a result if refreshDockerode is async then it completes at a somewhat unpredictable time later. The consequence of this is that you get a flash of "cannot connect" since the dockerode object isn't initialized yet, before it starts working. Also, tests fail miserably because each of the tree tests results in ~4 setting changes, thus four calls to refreshDockerode; eventually ext.dockerode would get overwritten by one of them during a test, causing it to fail.
There was a problem hiding this comment.
FWIW the tests don't change settings that affect dockerode. Perhaps we should be more selective in terms of which setting changes cause a refresh
There was a problem hiding this comment.
I wanted to but I'm not sure we can, without redefining the settings, which I'm not sure we can do. If the settings for the DOCKER_* environment variable settings were in their own subgroup, like docker.environment.*, we could be more specific; but since they're just docker.* we're kinda stuck.
There was a problem hiding this comment.
As discussed offline, we can filter on specific settings with e.affectsConfiguration, so I did that. Still has to be sync though to avoid the problem with the UI quickly flashing "cannot connect" on first activation.
Resolves #1199