feat: implement fail-fast monitoring to stop as soon as error/traceback is detected
This commit is contained in:
+9
-1
@@ -224,9 +224,10 @@ export async function pollUntilDone(
|
||||
shard,
|
||||
intervalMs,
|
||||
onProgress,
|
||||
shouldStop = () => false,
|
||||
) {
|
||||
let elapsed = 0;
|
||||
while (elapsed < targetTicks) {
|
||||
while (elapsed < targetTicks && !shouldStop()) {
|
||||
await sleep(intervalMs);
|
||||
const { time } = await api.time(shard);
|
||||
elapsed = time - startTick;
|
||||
@@ -332,6 +333,13 @@ export async function monitorConsole(api, opts) {
|
||||
lastProgressTick = elapsed;
|
||||
}
|
||||
},
|
||||
() => {
|
||||
// Fail-fast logic: stop monitoring if any 'fail' action is triggered
|
||||
if (opts.onTraceback === "fail" && state.sawTraceback) return true;
|
||||
if (opts.onErrorLog === "fail" && state.sawErrorLog) return true;
|
||||
if (opts.onWarningLog === "fail" && state.sawWarningLog) return true;
|
||||
return false;
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
// ── Step 5: always disconnect cleanly ────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user