fix: chain dropIndex before createIndex on ap_muted to prevent race condition

The non-async init() fired dropIndex and createIndex concurrently,
causing MongoDB to abort the index build (IndexBuildAborted error 276).
Chain createIndex via .then() so it runs after the drop completes.

Confab-Link: http://localhost:8080/sessions/e9d666ac-3c90-4298-9e92-9ac9d142bc06
This commit is contained in:
Ricardo
2026-03-02 11:40:43 +01:00
parent 76571b00ac
commit 9fa3412875
2 changed files with 22 additions and 13 deletions
+15 -6
View File
@@ -1000,18 +1000,27 @@ export default class ActivityPubEndpoint {
);
}
// Drop non-sparse indexes if they exist (created by earlier versions),
// then recreate with sparse:true so multiple null values are allowed.
this._collections.ap_muted.dropIndex("url_1").catch(() => {});
this._collections.ap_muted.dropIndex("keyword_1").catch(() => {});
// Muted collection — sparse unique indexes (allow multiple null values)
this._collections.ap_muted
.dropIndex("url_1")
.catch(() => {})
.then(() =>
this._collections.ap_muted.createIndex(
{ url: 1 },
{ unique: true, sparse: true, background: true },
);
),
)
.catch(() => {});
this._collections.ap_muted
.dropIndex("keyword_1")
.catch(() => {})
.then(() =>
this._collections.ap_muted.createIndex(
{ keyword: 1 },
{ unique: true, sparse: true, background: true },
);
),
)
.catch(() => {});
this._collections.ap_blocked.createIndex(
{ url: 1 },
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@rmdes/indiekit-endpoint-activitypub",
"version": "2.4.0",
"version": "2.4.1",
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
"keywords": [
"indiekit",