Skip to content

Node.js based forum software built for the modern web

fix: handle retry queue invalidation across a cluster

Opliko22b42f11dd18
diff --git a/src/activitypub/index.js b/src/activitypub/index.js
index e6bfc2c7a5..5531196d0b 100644
--- a/src/activitypub/index.js
+++ b/src/activitypub/index.js
@@ -12,6 +12,7 @@ const utils = require('../utils');
const ttl = require('../cache/ttl');
const lru = require('../cache/lru');
const batch = require('../batch');
+const pubsub = require('../pubsub');
const requestCache = ttl({ ttl: 1000 * 60 * 5 }); // 5 minutes
const ActivityPub = module.exports;
@@ -256,6 +257,13 @@ ActivityPub.get = async (type, id, uri) => {
ActivityPub.retryQueue = lru({ name: 'activitypub-retry-queue', max: 4000, ttl: 1000 * 60 * 60 * 24 * 60 });
+// handle clearing retry queue from another member of the cluster
+pubsub.on(`activitypub-retry-queue:lruCache:del`, (keys) => {
+ if (Array.isArray(keys)) {
+ keys.forEach(key => clearTimeout(ActivityPub.retryQueue.get(key)));
+ }
+});
+
async function sendMessage(uri, id, type, payload, attempts = 1) {
const keyData = await ActivityPub.getPrivateKey(type, id);
const headers = await ActivityPub.sign(keyData, uri, payload);