From e0508cbb0e968989c1982cb6aa02ffd3b57fa0ef Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 23 Feb 2024 19:07:40 -0500 Subject: [PATCH] admin: fixed admin scripts when network unreachable --- misc/admin/lib/geturl.js | 8 +++++--- misc/admin/src.ts/geturl.ts | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/misc/admin/lib/geturl.js b/misc/admin/lib/geturl.js index e890259a9..fb4b3ab95 100644 --- a/misc/admin/lib/geturl.js +++ b/misc/admin/lib/geturl.js @@ -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; }); diff --git a/misc/admin/src.ts/geturl.ts b/misc/admin/src.ts/geturl.ts index dbeed171e..9f8d52fc6 100644 --- a/misc/admin/src.ts/geturl.ts +++ b/misc/admin/src.ts/geturl.ts @@ -68,10 +68,10 @@ function nonnull(value: string): string { return value; } -function staller(duration: number): Promise { +function staller(duration: number, block?: boolean): Promise { 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