@@ -125,7 +125,15 @@ export async function updateDockerTunnelledNetworks(
125125
126126 await containerMutex . runExclusive ( async ( ) => {
127127 // Inspect() must happen inside the lock to avoid any possible races.
128- let container = await docker . getContainer ( containerName ) . inspect ( ) ;
128+ const container = await docker . getContainer ( containerName ) . inspect ( )
129+ . catch ( ( ) => undefined ) ;
130+
131+ if ( ! container ) {
132+ // We checked this before, so if it's now missing again then we're probably in
133+ // some race where the tunnel & other containers are being stopped en masse, or
134+ // some odd shutdown condition. Not the end of the world - just skip this update.
135+ return ;
136+ }
129137
130138 const expectedNetworks = _ . uniq ( [
131139 ...interceptedNetworks ,
@@ -158,7 +166,7 @@ export async function updateDockerTunnelledNetworks(
158166
159167// A map of proxy port (e.g. 8000) to the automatically mapped Docker tunnel port.
160168// Refreshed if it's somehow missing, or on every call to ensureDockerTunnelRunning(), e.g.
161- // async at every docker-proxy request & every container interception.
169+ // async at every docker-proxy request, every network event & every container interception.
162170const portCache : { [ proxyPort : string ] : number | Promise < number > | undefined } = { } ;
163171
164172export async function getDockerTunnelPort ( proxyPort : number ) : Promise < number > {
@@ -228,8 +236,7 @@ export async function stopDockerTunnel(proxyPort: number | 'all'): Promise<void>
228236
229237 await Promise . all ( containers . map ( async ( containerData ) => {
230238 const container = docker . getContainer ( containerData . Id ) ;
231- await container . kill ( ) . catch ( ( ) => { } ) ;
232- await container . remove ( ) . catch ( ( ) => { } ) ;
239+ await container . remove ( { force : true } ) . catch ( ( ) => { } ) ;
233240 } ) ) ;
234241 } ) ;
235242}
0 commit comments