admin: fixed admin scripts when network unreachable

This commit is contained in:
Richard Moore 2024-02-23 19:07:40 -05:00
parent fa825ddc94
commit e0508cbb0e
2 changed files with 8 additions and 6 deletions

@ -61,10 +61,12 @@ function nonnull(value) {
}
return value;
}
function staller(duration) {
function staller(duration, block) {
return new Promise((resolve) => {
const timer = setTimeout(resolve, duration);
timer.unref();
if (!block) {
timer.unref();
}
});
}
function _getUrl(href, options) {
@ -121,7 +123,7 @@ function getUrl(href, options) {
catch (e) {
error = e;
}
yield staller(1000);
yield staller(1000, true);
}
throw error;
});

@ -68,10 +68,10 @@ function nonnull(value: string): string {
return value;
}
function staller(duration: number): Promise<void> {
function staller(duration: number, block?: boolean): Promise<void> {
return new Promise((resolve) => {
const timer = setTimeout(resolve, duration);
timer.unref();
if (!block) { timer.unref(); }
});
}
@ -131,7 +131,7 @@ export async function getUrl(href: string, options?: Options): Promise<GetUrlRes
} catch (e) {
error = e;
}
await staller(1000);
await staller(1000, true);
}
throw error;
}