File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,14 +21,17 @@ import {
2121 stopDockerTunnel ,
2222} from './docker-tunnel-proxy' ;
2323import { ensureDockerInjectionVolumeExists } from './docker-data-injection' ;
24+ import { withTimeout } from '../../util/promise' ;
2425
2526let dockerAvailableCache : Promise < boolean > | undefined ;
2627
28+ const DOCKER_AVAILABILITY_TIMEOUT_MS = 3_000 ;
29+
2730export const isDockerAvailable = ( options : { logError ?: boolean } = { } ) => {
2831 if ( dockerAvailableCache ) return dockerAvailableCache ;
2932 else {
3033 dockerAvailableCache = ( async ( ) => { // Catch sync & async setup errors
31- return new Docker ( ) . info ( ) ;
34+ return withTimeout ( DOCKER_AVAILABILITY_TIMEOUT_MS , new Docker ( ) . info ( ) ) ;
3235 } ) ( )
3336 . then ( ( info : { OSType ?: 'windows' | 'linux' } ) => {
3437 if ( info . OSType === 'windows' ) {
@@ -203,4 +206,4 @@ export async function deleteAllInterceptedDockerData(proxyPort: number | 'all'):
203206 delete pendingDeactivations [ proxyPort ] ;
204207 } ) ( )
205208 ] ) as Promise < unknown > as Promise < void > ;
206- }
209+ }
Original file line number Diff line number Diff line change @@ -23,8 +23,11 @@ export async function waitUntil<T extends unknown>(
2323}
2424
2525export class TimeoutError extends CustomError {
26- constructor ( ) {
27- super ( 'Timeout' , { code : 'timeout' } ) ;
26+ constructor ( timeoutMs ?: number ) {
27+ super (
28+ timeoutMs === undefined ? 'Timeout' : `Timeout after ${ timeoutMs } ms` ,
29+ { code : 'timeout' }
30+ ) ;
2831 }
2932}
3033
@@ -35,6 +38,6 @@ export async function withTimeout<T>(
3538 return Promise . race ( [
3639 promise ,
3740 delay ( timeoutMs , { unref : true } )
38- . then ( ( ) => { throw new TimeoutError ( ) ; } )
41+ . then ( ( ) => { throw new TimeoutError ( timeoutMs ) ; } )
3942 ] ) ;
4043}
You can’t perform that action at this time.
0 commit comments