Skip to content

Commit

Permalink
CCA: Ignore exception from previous job for AsyncJobQueue
Browse files Browse the repository at this point in the history
Currently when pushing new job to an AsyncJobQueue, if the previous job
throws exception, then the new job will also throw with the same
exception. This cause some weird issue like b:227292523. Fix this by
ignoring exception from previous job.

(cherry picked from commit 3786691)

Bug: b:227292523
Test: manually test that b:227292523 is no longer reproducible
Change-Id: I4ccdc4cf701e70a8f4fa0c966e08c7b5f908d296
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3599456
Auto-Submit: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Wei Lee <wtlee@chromium.org>
Commit-Queue: Wei Lee <wtlee@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#995132}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3601954
Cr-Commit-Position: refs/branch-heads/4951@{#1050}
Cr-Branched-From: 27de622-refs/heads/main@{#982481}
  • Loading branch information
peter50216 authored and Chromium LUCI CQ committed Apr 26, 2022
1 parent 0909fa0 commit 8e05e8e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions ash/webui/camera_app_ui/resources/js/async_job_queue.ts
Expand Up @@ -14,7 +14,9 @@ export class AsyncJobQueue {
* @return Resolved with the job return value when the job is finished.
*/
push<T>(job: () => Promise<T>): Promise<T> {
const promise = this.promise.then(job);
const promise =
this.promise.catch(() => {/* ignore error from previous job */})
.then(job);
this.promise = promise;
return promise;
}
Expand Down Expand Up @@ -44,12 +46,14 @@ export class ClearableAsyncJobQueue {
* null if the job is cleared.
*/
push<T>(job: () => Promise<T>): Promise<T|null> {
const promise: Promise<T|null> = this.promise.then(() => {
if (this.clearing) {
return null;
}
return job();
});
const promise =
this.promise.catch(() => {/* ignore error from previous job */})
.then(() => {
if (this.clearing) {
return null;
}
return job();
});
this.promise = promise;
return promise;
}
Expand Down

0 comments on commit 8e05e8e

Please sign in to comment.