Allow task to recover after a failed graph start

PiperOrigin-RevId: 500324587
This commit is contained in:
Sebastian Schmidt 2023-01-06 21:04:57 -08:00 committed by Copybara-Service
parent b4ede6db7b
commit ed0054836a
2 changed files with 24 additions and 9 deletions

View File

@ -164,6 +164,7 @@ export abstract class TaskRunner {
/** Throws the error from the error listener if an error was raised. */
private handleErrors() {
try {
const errorCount = this.processingErrors.length;
if (errorCount === 1) {
// Re-throw error to get a more meaningful stacktrace
@ -173,8 +174,10 @@ export abstract class TaskRunner {
'Encountered multiple errors: ' +
this.processingErrors.map(e => e.message).join(', '));
}
} finally {
this.processingErrors = [];
}
}
/** Configures the `externalFile` option */
private setExternalFile(modelAssetBuffer?: Uint8Array): void {

View File

@ -139,6 +139,18 @@ describe('TaskRunner', () => {
}).toThrowError(/Test error 1, Test error 2/);
});
it('clears errors once thrown', () => {
taskRunner.enqueueError('Test error');
expect(() => {
taskRunner.setGraph(new Uint8Array(0), /* isBinary= */ true);
}).toThrowError(/Test error/);
expect(() => {
taskRunner.setGraph(new Uint8Array(0), /* isBinary= */ true);
}).not.toThrow();
});
it('verifies that at least one model asset option is provided', () => {
expect(() => {
taskRunner.setOptions({});