mark offline when 401 unauthorized

This commit is contained in:
pinks 2023-09-11 01:58:20 +02:00
parent 13bd410bdc
commit 721f3d0b0f
1 changed files with 6 additions and 2 deletions

View File

@ -50,7 +50,11 @@ export async function processJobs(): Promise<never> {
} }
if ( if (
err instanceof SdApiError && err instanceof SdApiError &&
(err.statusCode === 0 /* Network error */ || err.statusCode === 404) (
err.statusCode === 0 /* Network error */ ||
err.statusCode === 404 ||
err.statusCode === 401
)
) { ) {
runningWorkers.delete(worker.name); runningWorkers.delete(worker.name);
logger().warning( logger().warning(
@ -59,7 +63,7 @@ export async function processJobs(): Promise<never> {
} }
await job.delete().catch(() => undefined); await job.delete().catch(() => undefined);
if (!(err instanceof Grammy.GrammyError) || err.error_code !== 403 /* blocked bot */) { if (!(err instanceof Grammy.GrammyError) || err.error_code !== 403 /* blocked bot */) {
await jobStore.create(job.value); await jobStore.create(job.value);
} }
}) })
.finally(() => busyWorkers.delete(worker.name)); .finally(() => busyWorkers.delete(worker.name));