Skip to content

[TypeScript SDK] Process not returning properly after client stop / dangling promise in sendAndWait #136

Closed

Description

@sinedied

When try this simple example, the node process gets stuck after the client.stop() ends and doesn't return until the sendAndWait timeout expires. I tried changing the sendAndWait timeout duration and it effectively reduces or augments the time before the node process completed.

import { CopilotClient } from "@github/copilot-sdk";

const client = new CopilotClient();

try {
  await client.start();
  const session = await client.createSession({ model: "gpt-4.1" });
  const response = await session.sendAndWait({ prompt: "Say hello in french and stop" });
  console.log(response?.data.content);

  await session.destroy();
  console.log(`Session destroyed`);
} catch (error) {
  console.error("Error:", error);
} finally {
    const errors = await client.stop();
    if (errors.length > 0) {
      console.error("Cleanup errors:", errors);
    }
    console.log(`Client stopped`);
   // DO NOT force kill the process to show the dangling promise.
   // process.exit(0);
}

Since this is related to the sendAndWait timeout there might be a dangling promise there.

Activity

  1. github-actions commented on Jan 23, 2026

    @github-actions
    Contributor

    Thanks for reporting this issue! 👍

    I've labeled this as a bug affecting the Node.js SDK. The reproduction code is clear and the suspected root cause (dangling promise in sendAndWait) is helpful. This looks like a legitimate cleanup issue where the timeout timer isn't being properly cancelled when client.stop() is called.

    AI generated by Issue Triage Agent

  2. X4MU-L commented on Jan 23, 2026

    @X4MU-L

    +1

  3. DaiqianHu commented on Jan 23, 2026

    @DaiqianHu

    You need to run /login in Copilot CLI first?

  4. sinedied commented on Jan 23, 2026

    @sinedied
    ContributorAuthor

    @DaiqianHu unrelated, this happens after the session has successfully ended. And yes for the session to be successful, I'm logged in.

  5. added a commit that references this issue on Jan 27, 2026
    945ae37
  6. added a commit that references this issue on Feb 3, 2026
    9fed8da
  7. added a commit that references this issue on Feb 3, 2026
    d84e17d
  8. added a commit that references this issue on Aug 4, 2026
    f661fd9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions