Skip to content

Commit 15d6371

Browse files
committed
Enhance timeout exception handling in testSendAndWaitThrowsOnTimeout
1 parent f27eb12 commit 15d6371

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/test/java/com/github/copilot/sdk/CopilotSessionTest.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,24 +488,31 @@ void testCreateSessionWithCustomConfigDir() throws Exception {
488488

489489
// This test validates client-side timeout behavior. The snapshot has no
490490
// assistant response because the test expects timeout BEFORE completion.
491+
// Note: In CI mode, the proxy logs "No cached response found" errors to
492+
// stderr, but these are expected - the timeout still triggers correctly.
491493
@Test
492494
void testSendAndWaitThrowsOnTimeout() throws Exception {
493495
ctx.configureForTest("session", "sendandwait_throws_on_timeout");
494496

495497
try (CopilotClient client = ctx.createClient()) {
496498
CopilotSession session = client.createSession().get();
497499

498-
// Use a very short timeout that will definitely expire
500+
// Use a short timeout that will trigger before any response
499501
try {
500-
// Note: We use a command that takes time so timeout triggers before completion
501-
session.sendAndWait(new MessageOptions().setPrompt("Run 'sleep 2 && echo done'"), 100).get(5,
502+
session.sendAndWait(new MessageOptions().setPrompt("Run 'sleep 2 && echo done'"), 100).get(30,
502503
TimeUnit.SECONDS);
503504
fail("Expected timeout exception");
504505
} catch (Exception e) {
505-
// Should throw a timeout-related error
506-
assertTrue(e.getMessage().toLowerCase().contains("timeout")
507-
|| (e.getCause() != null && e.getCause().getMessage().toLowerCase().contains("timeout")),
508-
"Should throw timeout exception: " + e.getMessage());
506+
// Should throw a timeout-related error from sendAndWait
507+
String message = e.getMessage() != null ? e.getMessage().toLowerCase() : "";
508+
String causeMessage = e.getCause() != null && e.getCause().getMessage() != null
509+
? e.getCause().getMessage().toLowerCase()
510+
: "";
511+
assertTrue(
512+
message.contains("timeout") || message.contains("sendandwait timed out")
513+
|| causeMessage.contains("timeout") || causeMessage.contains("sendandwait timed out"),
514+
"Should throw timeout exception, got: " + e.getMessage()
515+
+ (e.getCause() != null ? " caused by: " + e.getCause().getMessage() : ""));
509516
}
510517

511518
session.close();

0 commit comments

Comments
 (0)