From cf3ea7e3da269a06430c5cbfdfd1d8e944802b2b Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Fri, 16 Oct 2020 12:22:57 +0200 Subject: [PATCH] Increase activation timeout for ADB only to 10s With emulators (e.g. Genymotion) and an initial fresh install of the app, setup can take longer than the one second that the API allows by default, so we boost that a little, to better track interceptor success rates and spot issues. --- src/api-server.ts | 2 +- src/interceptors/android/android-adb-interceptor.ts | 2 ++ src/interceptors/index.ts | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api-server.ts b/src/api-server.ts index 4815d890..9c94df95 100644 --- a/src/api-server.ts +++ b/src/api-server.ts @@ -154,7 +154,7 @@ const buildResolvers = ( isActivable: (interceptor: Interceptor) => { return withFallback( interceptor.isActivable(), - INTERCEPTOR_TIMEOUT, + interceptor.activationTimeout || INTERCEPTOR_TIMEOUT, false ); }, diff --git a/src/interceptors/android/android-adb-interceptor.ts b/src/interceptors/android/android-adb-interceptor.ts index 89802b33..686a4842 100644 --- a/src/interceptors/android/android-adb-interceptor.ts +++ b/src/interceptors/android/android-adb-interceptor.ts @@ -54,6 +54,8 @@ export class AndroidAdbInterceptor implements Interceptor { }; } + activationTimeout = 10000; // Increase timeout for this interceptor to 10s, as initial setup takes a while + async activate(proxyPort: number, options: { deviceId: string }): Promise { diff --git a/src/interceptors/index.ts b/src/interceptors/index.ts index c0c18657..44f0d2c3 100644 --- a/src/interceptors/index.ts +++ b/src/interceptors/index.ts @@ -32,6 +32,8 @@ export interface Interceptor { isActive(proxyPort: number): boolean; activate(proxyPort: number, options?: any): Promise; + activationTimeout?: number; + deactivate(proxyPort: number, options?: any): Promise; deactivateAll(): Promise; }