admin: fixed admin scripts when network unreachable
This commit is contained in:
parent
fa825ddc94
commit
e0508cbb0e
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user