Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

route a failed GC-module import through the same retry path as a failed sweep

[._.]/ Adam Eivy080a0a44e564
diff --git a/server/services/fableLoom/store.js b/server/services/fableLoom/store.js
index 6e4d6e8348..3dfccdb4b9 100644
--- a/server/services/fableLoom/store.js
+++ b/server/services/fableLoom/store.js
@@ -47,7 +47,7 @@ function makeFileBackend() {
// directly — same conservative "unparseable deletedAt is kept" rule.
listLiveIds: async () => {
const records = await collection.loadAll();
- return records.filter((r) => r?.deleted !== true).map((r) => r.id);
+ return records.filter((r) => r && r.deleted !== true).map((r) => r.id);
},
listTombstoneIdsBefore: async (beforeMs) => {
const records = await collection.loadAll();
diff --git a/server/services/syncOrchestrator.js b/server/services/syncOrchestrator.js
index 76464dfe67..a3cfc1bc32 100644
--- a/server/services/syncOrchestrator.js
+++ b/server/services/syncOrchestrator.js
@@ -1009,20 +1009,22 @@ export function initSyncOrchestrator() {
* Stamps `lastTombstoneSweepAt` BEFORE awaiting the sweep (not after) so a
* slow sweep still under way can't have its claimed slot re-entered by a
* later tick once the hour rolls over — the same reasoning as the module-
- * level doc comment. A sweep that FAILS resets the stamp back to 0, though,
- * so a transient error (e.g. the DB blips) retries on the very next tick
- * instead of going quiet for a full hour.
+ * level doc comment. Either the dynamic import OR the sweep itself FAILING
+ * resets the stamp back to 0, though, so a transient error (the DB blips, or
+ * the GC module briefly fails to load) retries on the very next tick instead
+ * of going quiet for a full hour.
*/
async function runTombstoneSweep() {
const now = Date.now();
if (lastTombstoneSweepAt !== 0 && now - lastTombstoneSweepAt < TOMBSTONE_SWEEP_INTERVAL_MS) return;
lastTombstoneSweepAt = now;
- const { sweepTombstones } = await import('./sharing/tombstoneGc.js');
- const result = await sweepTombstones().catch((err) => {
- console.error(`❌ Tombstone sweep failed: ${err.message}`);
- lastTombstoneSweepAt = 0;
- return null;
- });
+ const result = await import('./sharing/tombstoneGc.js')
+ .then(({ sweepTombstones }) => sweepTombstones())
+ .catch((err) => {
+ console.error(`❌ Tombstone sweep failed: ${err.message}`);
+ lastTombstoneSweepAt = 0;
+ return null;
+ });
if (result && (result.universes > 0 || result.series > 0 || result.issues > 0 || result.collections > 0)) {
// "series" is already its own plural so no s-suffix toggle needed there.
const universes = `${result.universes} universe${result.universes === 1 ? '' : 's'}`;
diff --git a/server/services/universeBuilder/store.js b/server/services/universeBuilder/store.js
index 472109054a..e87e33191a 100644
--- a/server/services/universeBuilder/store.js
+++ b/server/services/universeBuilder/store.js
@@ -97,7 +97,7 @@ function makeFileBackend(dir) {
// "unparseable deletedAt is kept" rule.
listLiveIds: async () => {
const records = await listRaw();
- return records.filter((r) => r?.deleted !== true).map((r) => r.id);
+ return records.filter((r) => r && r.deleted !== true).map((r) => r.id);
},
listTombstoneIdsBefore: async (beforeMs) => {
const records = await listRaw();