From 442e98e4da6025f5c2e61ad5de1df21d69816023 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 4 Apr 2024 12:22:13 -0400 Subject: [PATCH] fix: add timeout on activitypub.get, tweak upgrade script --- src/activitypub/index.js | 1 + src/upgrades/4.0.0/remote_user_urls.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/activitypub/index.js b/src/activitypub/index.js index e9b114b8ad..50d4823175 100644 --- a/src/activitypub/index.js +++ b/src/activitypub/index.js @@ -202,6 +202,7 @@ ActivityPub.get = async (type, id, uri) => { ...headers, Accept: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', }, + timeout: 5000, }); if (!String(response.statusCode).startsWith('2')) { diff --git a/src/upgrades/4.0.0/remote_user_urls.js b/src/upgrades/4.0.0/remote_user_urls.js index 9469d6cf93..4c24ebe601 100644 --- a/src/upgrades/4.0.0/remote_user_urls.js +++ b/src/upgrades/4.0.0/remote_user_urls.js @@ -12,7 +12,14 @@ module.exports = { method: async () => { const batch = require('../../batch'); const { progress } = this; + const interval = 5000; - await batch.processSortedSet('usersRemote:lastCrawled', async ids => await activitypub.actors.assert(ids, { update: true }), { progress }); + await batch.processSortedSet('usersRemote:lastCrawled', async (ids) => { + try { + await activitypub.actors.assert(ids, { update: true }); + } catch (e) { + // noop + } + }, { progress, interval }); }, };