Skip to content

Commit 932cdfe

Browse files
committed
Clean up activation timeout logic, which didn't work as intended
Seems like I misunderstood/confused myself somehow in cf3ea7e: this doesn't configure an activation timeout (which doesn't really exist, though we report errors at 30s+) but instead sets the isActivable timeout. That's not actually very important for ADB (should be quick, perhaps after the first check) AFAICT, and it's definitely not what was described/documented for this change. Now, we extend the time a little for the JVM and ADB, both of which may need to wait for external processes (especially slow on Mac) but otherwise keep the default 1s for isActivable and 30s warning for activation itself.
1 parent 2964a33 commit 932cdfe

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/api-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ const buildResolvers = (
167167
isActivable: (interceptor: Interceptor) => {
168168
return withFallback(
169169
interceptor.isActivable(),
170-
interceptor.activationTimeout || INTERCEPTOR_TIMEOUT,
170+
interceptor.activableTimeout || INTERCEPTOR_TIMEOUT,
171171
false
172172
);
173173
},

src/interceptors/android/android-adb-interceptor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export class AndroidAdbInterceptor implements Interceptor {
4545
return (await getConnectedDevices(this.adbClient)).length > 0;
4646
}
4747

48+
activableTimeout = 3000; // Increase timeout for device detection slightly
49+
4850
isActive(): boolean {
4951
return false;
5052
}
@@ -55,8 +57,6 @@ export class AndroidAdbInterceptor implements Interceptor {
5557
};
5658
}
5759

58-
activationTimeout = 10000; // Increase timeout for this interceptor to 10s, as initial setup takes a while
59-
6060
async activate(proxyPort: number, options: {
6161
deviceId: string
6262
}): Promise<void | {}> {

src/interceptors/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ export interface Interceptor {
2929
id: string;
3030
version: string;
3131

32-
getMetadata?(type: 'summary' | 'detailed'): any;
32+
getMetadata?(type: 'summary' | 'detailed'): Promise<any>;
3333

3434
isActivable(): Promise<boolean>;
35+
activableTimeout?: number;
36+
3537
isActive(proxyPort: number): boolean;
3638

3739
activate(proxyPort: number, options?: any): Promise<void | {}>;
38-
activationTimeout?: number;
3940

4041
deactivate(proxyPort: number, options?: any): Promise<void | {}>;
4142
deactivateAll(): Promise<void | {}>;

src/interceptors/jvm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ export class JvmInterceptor implements Interceptor {
8888
[pid: string]: number // PID -> proxy port
8989
} = {};
9090

91-
activationTimeout = 2000; // Increase the timeout slightly for this
92-
9391
constructor(private config: HtkConfig) { }
9492

9593
async isActivable(): Promise<boolean> {
9694
return !!await javaBinPromise;
9795
}
9896

97+
activableTimeout = 2000; // Increase the timeout slightly for this
98+
9999
isActive(proxyPort: number | string) {
100100
return _.some(this.interceptedProcesses, (port) => port === proxyPort);
101101
}

0 commit comments

Comments
 (0)