Skip to content

Commit 6ecdcb6

Browse files
committed
Fix Docker tunnel port refresh error handling
Previously, because we built a separate promise that wasn't awaited, failures in ensure() or kill() were not caught by the catch clause, and so did not clear the cache, so were persisted indefinitely. This happened any time there was a blip in tunnel refreshing. Instead, we now build the flow with await, and error handling should work as expected.
1 parent fd0fbd6 commit 6ecdcb6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/interceptors/docker/docker-tunnel-proxy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ export async function refreshDockerTunnelPortCache(proxyPort: number): Promise<n
205205
.inspect().catch(() => undefined);
206206
if (!container) {
207207
// Can't get the container - recreate it (refreshing the port automatically)
208-
return ensureDockerTunnelRunning(proxyPort)
209-
.then(() => getDockerTunnelPort(proxyPort));
208+
await ensureDockerTunnelRunning(proxyPort)
209+
return getDockerTunnelPort(proxyPort);
210210
}
211211

212212
const portMappings = container.NetworkSettings.Ports['1080/tcp'];
@@ -215,9 +215,9 @@ export async function refreshDockerTunnelPortCache(proxyPort: number): Promise<n
215215
if (!localPort) {
216216
// This can happen if the networks of the container are changed manually. In some cases
217217
// this can result in the mapping being lots. Kill & restart the container.
218-
return docker.getContainer(containerName).kill()
219-
.then(() => ensureDockerTunnelRunning(proxyPort))
220-
.then(() => getDockerTunnelPort(proxyPort));
218+
await docker.getContainer(containerName).kill();
219+
await ensureDockerTunnelRunning(proxyPort);
220+
return getDockerTunnelPort(proxyPort);
221221
}
222222

223223
const port = parseInt(localPort.HostPort, 10);

0 commit comments

Comments
 (0)