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.