Merge pull request #1302 from hgiesel/hookhandle

Catch reviewer hook errors in two ways
This commit is contained in:
Damien Elmes 2021-07-20 13:55:57 +10:00 committed by GitHub
commit b61e90e995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View File

@ -27,14 +27,21 @@ export function getTypedAnswer(): string | null {
return typeans?.value ?? null;
}
function _runHook(arr: Array<Callback>): Promise<void[]> {
function _runHook(
hooks: Array<Callback>
): Promise<PromiseSettledResult<void | Promise<void>>[]> {
const promises: (Promise<void> | void)[] = [];
for (let i = 0; i < arr.length; i++) {
promises.push(arr[i]());
for (const hook of hooks) {
try {
const result = hook();
promises.push(result);
} catch (error) {
console.log("Hook failed: ", error);
}
}
return Promise.all(promises);
return Promise.allSettled(promises);
}
let _updatingQueue: Promise<void> = Promise.resolve();

View File

@ -3,7 +3,14 @@
"compilerOptions": {
"target": "es6",
"module": "es6",
"lib": ["es2017", "es2019.array", "es2018.promise", "dom", "dom.iterable"],
"lib": [
"es2017",
"es2019.array",
"es2018.promise",
"es2020.promise",
"dom",
"dom.iterable"
],
"baseUrl": ".",
"paths": {
"lib/*": ["../bazel-bin/ts/lib/*"],