Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion nodejs/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function getBundledCliPath(): string {
* ```
*/
export class CopilotClient {
private cliStartTimeout: ReturnType<typeof setTimeout> | null = null;
private cliProcess: ChildProcess | null = null;
private connection: MessageConnection | null = null;
private socket: Socket | null = null;
Expand Down Expand Up @@ -540,6 +541,10 @@ export class CopilotClient {
}
this.cliProcess = null;
}
if (this.cliStartTimeout) {
clearTimeout(this.cliStartTimeout);
this.cliStartTimeout = null;
}
Comment on lines +544 to +547
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s now important cleanup logic for cliStartTimeout, but there are currently no unit tests covering stop()/forceStop() behavior (this file’s tests mainly use forceStop() as cleanup). Adding a small unit test with fake timers to assert that stop() (and forceStop()) clears a pending startup timeout would help prevent regressions where short-lived scripts hang for ~10s again.

This issue also appears in the following locations of the same file:

  • line 621
  • line 1534

Copilot uses AI. Check for mistakes.

this.state = "disconnected";
this.actualPort = null;
Expand Down Expand Up @@ -613,6 +618,11 @@ export class CopilotClient {
this.cliProcess = null;
}

if (this.cliStartTimeout) {
clearTimeout(this.cliStartTimeout);
this.cliStartTimeout = null;
}

this.state = "disconnected";
this.actualPort = null;
this.stderrBuffer = "";
Expand Down Expand Up @@ -1522,7 +1532,7 @@ export class CopilotClient {
});

// Timeout after 10 seconds
setTimeout(() => {
this.cliStartTimeout = setTimeout(() => {
if (!resolved) {
resolved = true;
reject(new Error("Timeout waiting for CLI server to start"));
Expand Down
Loading