ralph-prd 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ralph/lib/transport.mjs +12 -4
package/package.json
CHANGED
package/ralph/lib/transport.mjs
CHANGED
|
@@ -26,7 +26,7 @@ import { relative } from 'path';
|
|
|
26
26
|
/** Timeout for the preflight check only — should always be fast. */
|
|
27
27
|
const PREFLIGHT_TIMEOUT_MS = 30_000;
|
|
28
28
|
|
|
29
|
-
/** Default timeout for send() — 20 minutes per CLI session. */
|
|
29
|
+
/** Default timeout for send() — 20 minutes of inactivity per CLI session. */
|
|
30
30
|
const SEND_TIMEOUT_MS = 20 * 60 * 1000;
|
|
31
31
|
|
|
32
32
|
const CLI_FLAGS = [
|
|
@@ -371,16 +371,24 @@ export async function send(prompt, { onChunk, signal, timeoutMs } = {}) {
|
|
|
371
371
|
const child = spawn(cliBin, CLI_FLAGS, { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
372
372
|
|
|
373
373
|
// ── Timeout: kills the CLI if no output arrives within the timeout window ──
|
|
374
|
-
|
|
374
|
+
// This is a no-activity timeout, not a hard cap — it resets on every stdout
|
|
375
|
+
// chunk so long-running tasks that keep producing output are never killed.
|
|
376
|
+
let timer = setTimeout(onTimeout, timeout);
|
|
377
|
+
function onTimeout() {
|
|
375
378
|
child.kill();
|
|
376
379
|
done(reject, new TransportError(
|
|
377
|
-
`\`claude\` CLI timed out after ${(timeout / 1000).toFixed(0)}s with no
|
|
380
|
+
`\`claude\` CLI timed out after ${(timeout / 1000).toFixed(0)}s with no output. ` +
|
|
378
381
|
'The session may have hung or lost connectivity.',
|
|
379
382
|
'timeout'
|
|
380
383
|
));
|
|
381
|
-
}
|
|
384
|
+
}
|
|
385
|
+
function resetTimer() {
|
|
386
|
+
clearTimeout(timer);
|
|
387
|
+
timer = setTimeout(onTimeout, timeout);
|
|
388
|
+
}
|
|
382
389
|
|
|
383
390
|
child.stdout.on('data', (chunk) => {
|
|
391
|
+
resetTimer();
|
|
384
392
|
lineBuffer += chunk.toString();
|
|
385
393
|
const lines = lineBuffer.split('\n');
|
|
386
394
|
lineBuffer = lines.pop() ?? '';
|