mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
retr (#147442)
This commit is contained in:
@@ -149,6 +149,21 @@ export function timeout(i: number) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function retryWithRestart(app: Application, testFn: () => Promise<unknown>, retries = 3, timeoutMs = 20000): Promise<unknown> {
|
||||
for (let i = 0; i < retries; i++) {
|
||||
const result = await Promise.race([
|
||||
testFn().then(() => true, error => { throw error; }),
|
||||
timeout(timeoutMs).then(() => false)
|
||||
]);
|
||||
|
||||
if (result) {
|
||||
return;
|
||||
}
|
||||
|
||||
await app.restart();
|
||||
}
|
||||
}
|
||||
|
||||
export interface ITask<T> {
|
||||
(): T;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user