Skip to content

Commit ea81206

Browse files
committed
fix: set up timeout with daemon thread in CopilotSession to prevent JVM exit
1 parent b988c55 commit ea81206

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/com/github/copilot/sdk/CopilotSession.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,12 @@ public CompletableFuture<AssistantMessageEvent> sendAndWait(MessageOptions optio
239239
return null;
240240
});
241241

242-
// Set up timeout
243-
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
242+
// Set up timeout with daemon thread so it doesn't prevent JVM exit
243+
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(r -> {
244+
Thread t = new Thread(r, "sendAndWait-timeout");
245+
t.setDaemon(true);
246+
return t;
247+
});
244248
scheduler.schedule(() -> {
245249
if (!future.isDone()) {
246250
future.completeExceptionally(new TimeoutException("sendAndWait timed out after " + timeoutMs + "ms"));

0 commit comments

Comments
 (0)