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:
@@ -1,6 +1,7 @@
|
||||
import * as plugins from './taskbuffer.plugins.js';
|
||||
|
||||
import { Task, type ITaskFunction } from './taskbuffer.classes.task.js';
|
||||
import { logger } from './taskbuffer.logging.js';
|
||||
|
||||
export class TaskDebounced<T = unknown> extends Task {
|
||||
private _debouncedTaskFunction: ITaskFunction;
|
||||
@@ -22,8 +23,17 @@ export class TaskDebounced<T = unknown> extends Task {
|
||||
.pipe(
|
||||
plugins.smartrx.rxjs.ops.debounceTime(optionsArg.debounceTimeInMillis),
|
||||
)
|
||||
.subscribe((x) => {
|
||||
this.taskFunction(x);
|
||||
.subscribe({
|
||||
next: async (x) => {
|
||||
try {
|
||||
await this.taskFunction(x);
|
||||
} catch (err) {
|
||||
logger.log('error', `TaskDebounced "${this.name || 'unnamed'}" failed: ${err instanceof Error ? err.message : String(err)}`);
|
||||
}
|
||||
},
|
||||
error: (err) => {
|
||||
logger.log('error', `TaskDebounced "${this.name || 'unnamed'}" observable error: ${err instanceof Error ? err.message : String(err)}`);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user