Skip to content

Node.js based forum software built for the modern web

fix: guard against infinite loop during topic purge batch call

Julian Lam6272d059e768
diff --git a/src/topics/delete.js b/src/topics/delete.js
index 4e7f5d1400..267190b75b 100644
--- a/src/topics/delete.js
+++ b/src/topics/delete.js
@@ -64,6 +64,7 @@ module.exports = function (Topics) {
const mainPid = await Topics.getTopicField(tid, 'mainPid');
await batch.processSortedSet(`tid:${tid}:posts`, async (pids) => {
await posts.purge(pids, uid);
+ await db.sortedSetRemove(`tid:${tid}:posts`, pids); // Guard against infinite loop if pid already does not exist in db
}, { alwaysStartAt: 0, batch: 500 });
await posts.purge(mainPid, uid);
await Topics.purge(tid, uid);