Skip to content

Commit 23452bd

Browse files
committed
Add timeout to calibrateDelay to prevent CI hangs
The calibration shSync calls used delay=0 with no timeout, which could block indefinitely if prompt detection fails (e.g. on slow SSH containers in CI where output arrives in multiple TCP fragments). Add a 10-second timeout per calibration call and gracefully fall back to the default delay if any call times out.
1 parent f2c5c49 commit 23452bd

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

qDup-core/src/main/java/io/hyperfoil/tools/qdup/shell/AbstractShell.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,31 @@ private void calibrateDelay() {
357357
int originalDelay = getDelay();
358358
setDelay(0);
359359

360+
// Use a timeout for calibration shSync calls to avoid hanging if prompt
361+
// detection fails with delay=0 (e.g. slow SSH containers in CI)
362+
int timeoutSeconds = 10;
363+
360364
// Warmup: discard first measurement to avoid SSH channel setup overhead
361365
calibrating = true;
362-
shSync("echo qdup_ping");
366+
SyncResponse warmup = shSync("echo qdup_ping", null, timeoutSeconds);
367+
if (warmup.timedOut()) {
368+
// Shell is too slow or unresponsive — keep default delay
369+
calibrating = false;
370+
setDelay(originalDelay);
371+
logger.warnf("%s calibration warmup timed out, keeping default delay %dms", getName(), originalDelay);
372+
return;
373+
}
363374

364375
long maxLatencyNs = 0;
365376
int samples = 3;
366377
for (int i = 0; i < samples; i++) {
367-
shSync("echo qdup_ping");
378+
SyncResponse resp = shSync("echo qdup_ping", null, timeoutSeconds);
379+
if (resp.timedOut()) {
380+
calibrating = false;
381+
setDelay(originalDelay);
382+
logger.warnf("%s calibration sample %d timed out, keeping default delay %dms", getName(), i, originalDelay);
383+
return;
384+
}
368385
if (lastCalibrationNs > maxLatencyNs) {
369386
maxLatencyNs = lastCalibrationNs;
370387
}

0 commit comments

Comments
 (0)