@@ -125,7 +125,15 @@ export async function updateDockerTunnelledNetworks(
125
125
126
126
await containerMutex . runExclusive ( async ( ) => {
127
127
// 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
+ }
129
137
130
138
const expectedNetworks = _ . uniq ( [
131
139
...interceptedNetworks ,
@@ -158,7 +166,7 @@ export async function updateDockerTunnelledNetworks(
158
166
159
167
// A map of proxy port (e.g. 8000) to the automatically mapped Docker tunnel port.
160
168
// 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.
162
170
const portCache : { [ proxyPort : string ] : number | Promise < number > | undefined } = { } ;
163
171
164
172
export async function getDockerTunnelPort ( proxyPort : number ) : Promise < number > {
@@ -228,8 +236,7 @@ export async function stopDockerTunnel(proxyPort: number | 'all'): Promise<void>
228
236
229
237
await Promise . all ( containers . map ( async ( containerData ) => {
230
238
const container = docker . getContainer ( containerData . Id ) ;
231
- await container . kill ( ) . catch ( ( ) => { } ) ;
232
- await container . remove ( ) . catch ( ( ) => { } ) ;
239
+ await container . remove ( { force : true } ) . catch ( ( ) => { } ) ;
233
240
} ) ) ;
234
241
} ) ;
235
242
}
0 commit comments