BREAKING CHANGE(taskbuffer): Change default Task error handling: trigger() now rejects when taskFunction throws; add catchErrors option (default false) to preserve previous swallow behavior; track errors (lastError, errorCount) and expose them in metadata; improve error propagation and logging across runners, chains, parallels and debounced tasks; add tests and documentation for new behavior.

This commit is contained in:
2026-01-25 23:29:00 +00:00
parent 905ca97b6a
commit 248383aab1
16 changed files with 575 additions and 63 deletions

View File

@@ -1,4 +1,5 @@
import { Task } from './taskbuffer.classes.task.js';
import { logger } from './taskbuffer.logging.js';
export class BufferRunner {
public task: Task;
@@ -24,9 +25,19 @@ export class BufferRunner {
private async _run(x: any) {
this.task.running = true;
while (this.bufferCounter > 0) {
const result = await Task.runTask(this.task, { x: x });
this.bufferCounter--;
this.task.cycleCounter.informOfCycle(result);
try {
const result = await Task.runTask(this.task, { x: x });
this.bufferCounter--;
this.task.cycleCounter.informOfCycle(result);
} catch (err) {
logger.log('error', `BufferRunner: task "${this.task.name || 'unnamed'}" failed: ${err instanceof Error ? err.message : String(err)}`);
this.bufferCounter--;
if (this.task.catchErrors) {
this.task.cycleCounter.informOfCycle(undefined);
} else {
this.task.cycleCounter.informOfCycleError(err instanceof Error ? err : new Error(String(err)));
}
}
}
this.task.running = false;
}