Skip to content

Commit e0508cb

Browse files
committed
admin: fixed admin scripts when network unreachable
1 parent fa825dd commit e0508cb

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

misc/admin/lib/geturl.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ function nonnull(value) {
6161
}
6262
return value;
6363
}
64-
function staller(duration) {
64+
function staller(duration, block) {
6565
return new Promise((resolve) => {
6666
const timer = setTimeout(resolve, duration);
67-
timer.unref();
67+
if (!block) {
68+
timer.unref();
69+
}
6870
});
6971
}
7072
function _getUrl(href, options) {
@@ -121,7 +123,7 @@ function getUrl(href, options) {
121123
catch (e) {
122124
error = e;
123125
}
124-
yield staller(1000);
126+
yield staller(1000, true);
125127
}
126128
throw error;
127129
});

misc/admin/src.ts/geturl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ function nonnull(value: string): string {
6868
return value;
6969
}
7070

71-
function staller(duration: number): Promise<void> {
71+
function staller(duration: number, block?: boolean): Promise<void> {
7272
return new Promise((resolve) => {
7373
const timer = setTimeout(resolve, duration);
74-
timer.unref();
74+
if (!block) { timer.unref(); }
7575
});
7676
}
7777

@@ -131,7 +131,7 @@ export async function getUrl(href: string, options?: Options): Promise<GetUrlRes
131131
} catch (e) {
132132
error = e;
133133
}
134-
await staller(1000);
134+
await staller(1000, true);
135135
}
136136
throw error;
137137
}

0 commit comments

Comments
 (0)