From 9db437c8155f3563a33e22ed2896072a9f1fbdb0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 13 Oct 2021 11:47:32 +0200 Subject: Process slow followers in unicast job queue --- .../lib/job-queue/handlers/activitypub-http-broadcast.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'server/lib/job-queue/handlers/activitypub-http-broadcast.ts') diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts index 9b0bb6574..fbf01d276 100644 --- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts @@ -1,10 +1,10 @@ import { map } from 'bluebird' import { Job } from 'bull' +import { ActorFollowHealthCache } from '@server/lib/actor-follow-health-cache' import { ActivitypubHttpBroadcastPayload } from '@shared/models' import { logger } from '../../../helpers/logger' import { doRequest } from '../../../helpers/requests' import { BROADCAST_CONCURRENCY } from '../../../initializers/constants' -import { ActorFollowScoreCache } from '../../files-cache' import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' async function processActivityPubHttpBroadcast (job: Job) { @@ -25,13 +25,17 @@ async function processActivityPubHttpBroadcast (job: Job) { const badUrls: string[] = [] const goodUrls: string[] = [] - await map(payload.uris, uri => { - return doRequest(uri, options) - .then(() => goodUrls.push(uri)) - .catch(() => badUrls.push(uri)) + await map(payload.uris, async uri => { + try { + await doRequest(uri, options) + goodUrls.push(uri) + } catch (err) { + logger.debug('HTTP broadcast to %s failed.', uri, { err }) + badUrls.push(uri) + } }, { concurrency: BROADCAST_CONCURRENCY }) - return ActorFollowScoreCache.Instance.updateActorFollowsScore(goodUrls, badUrls) + return ActorFollowHealthCache.Instance.updateActorFollowsHealth(goodUrls, badUrls) } // --------------------------------------------------------------------------- -- cgit v1.2.3