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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: stop annotation exports when source reads fail (#6975)
[._.]/ Adam Eivy3358033dcad9
diff --git a/server/services/sharing/annotationsSync.js b/server/services/sharing/annotationsSync.jsindex cd3cd3f1d7..7c9438070f 100644--- a/server/services/sharing/annotationsSync.js+++ b/server/services/sharing/annotationsSync.js@@ -210,7 +210,8 @@ async function flushAll() {const [buckets, senderInstanceId, localAnnotations] = await Promise.all([listBuckets().catch(() => []),getInstanceId().catch(() => null),- listLocalAuthorAnnotations().catch(() => ({})),+ // A failed source read is not a deletion: abort before tombstone synthesis.+ listLocalAuthorAnnotations(),]);if (!senderInstanceId || senderInstanceId === UNKNOWN_INSTANCE_ID) return;const autoMerge = buckets.filter((b) => b.mode === 'auto-merge');diff --git a/server/services/sharing/annotationsSync.test.js b/server/services/sharing/annotationsSync.test.jsindex 5527aa86c6..1bc946b65d 100644--- a/server/services/sharing/annotationsSync.test.js+++ b/server/services/sharing/annotationsSync.test.js@@ -396,3 +396,44 @@ describe('sharing/annotationsSync.listBucketAssetKeys cache', () => {expect(listManifestFilenames).toHaveBeenCalledTimes(1);});});+++describe('sharing/annotationsSync event flush', () => {+ it('contains a failed annotation read without publishing tombstones, then retries on the next event', async () => {+ const { onLocalAnnotationChange, listLocalAuthorAnnotations } = await import('../mediaAnnotations.js');+ const { listBuckets } = await import('./buckets.js');+ const { listManifestFilenames, readManifest } = await import('./manifest.js');+ const { existsSync } = await import('fs');+ const source = bucket();+ const recordPath = '/mock/bucket/records/media-annotations/local-instance.json';+ const prior = { annotations: { 'image:kept.png': { note: 'Keep this' } } };+ fileStore.clear();+ fileStore.set(recordPath, prior);+ writeCalls.length = 0;+ svc.__resetBucketAssetKeysCache();+ listBuckets.mockResolvedValue([source]);+ listManifestFilenames.mockResolvedValue(['asset.json']);+ readManifest.mockResolvedValue({ assetRefs: [{ kind: 'image', ref: 'kept.png' }] });+ existsSync.mockReturnValue(true);+ listLocalAuthorAnnotations.mockRejectedValueOnce(Object.assign(new Error('Unreadable annotation store'), { code: 'UNREADABLE_STORE' }));+ const errorLog = vi.spyOn(console, 'error').mockImplementation(() => {});+ vi.useFakeTimers();+ try {+ svc.initAnnotationsSync();+ const changed = onLocalAnnotationChange.mock.calls.at(-1)[0];+ changed();+ await vi.advanceTimersByTimeAsync(2000);+ expect(fileStore.get(recordPath)).toEqual(prior);+ expect(writeCalls).toHaveLength(0);+ expect(errorLog).toHaveBeenCalledWith(expect.stringContaining('flushAll failed: Unreadable annotation store'));++ listLocalAuthorAnnotations.mockResolvedValue({ 'image:kept.png': { note: 'Repaired' } });+ changed();+ await vi.advanceTimersByTimeAsync(2000);+ expect(fileStore.get(recordPath).annotations['image:kept.png'].note).toBe('Repaired');+ } finally {+ vi.useRealTimers();+ errorLog.mockRestore();+ }+ });+});