Skip to content

Commit cdf5f5e

Browse files
committed
Clear the CLI startup timeout when we are told to stop
Otherwise we won't terminate until the 10 seconds are up.
1 parent e0a9028 commit cdf5f5e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

nodejs/src/client.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ function getBundledCliPath(): string {
199199
* ```
200200
*/
201201
export class CopilotClient {
202+
private cliStartTimeout: ReturnType<typeof setTimeout> | null = null;
202203
private cliProcess: ChildProcess | null = null;
203204
private connection: MessageConnection | null = null;
204205
private socket: Socket | null = null;
@@ -540,6 +541,10 @@ export class CopilotClient {
540541
}
541542
this.cliProcess = null;
542543
}
544+
if (this.cliStartTimeout) {
545+
clearTimeout(this.cliStartTimeout);
546+
this.cliStartTimeout = null;
547+
}
543548

544549
this.state = "disconnected";
545550
this.actualPort = null;
@@ -613,6 +618,11 @@ export class CopilotClient {
613618
this.cliProcess = null;
614619
}
615620

621+
if (this.cliStartTimeout) {
622+
clearTimeout(this.cliStartTimeout);
623+
this.cliStartTimeout = null;
624+
}
625+
616626
this.state = "disconnected";
617627
this.actualPort = null;
618628
this.stderrBuffer = "";
@@ -1522,7 +1532,7 @@ export class CopilotClient {
15221532
});
15231533

15241534
// Timeout after 10 seconds
1525-
setTimeout(() => {
1535+
this.cliStartTimeout = setTimeout(() => {
15261536
if (!resolved) {
15271537
resolved = true;
15281538
reject(new Error("Timeout waiting for CLI server to start"));

0 commit comments

Comments
 (0)