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

fix: widen isTransientFsError to include EBUSY and EIO

Adam Eivye30b1a8e9c72
diff --git a/server/services/mortalLoomStore.js b/server/services/mortalLoomStore.js
index 55bd8806c0..27f5c63675 100644
--- a/server/services/mortalLoomStore.js
+++ b/server/services/mortalLoomStore.js
@@ -36,8 +36,12 @@ function normalizePath(rawPath) {
// iCloud's `bird` daemon takes brief exclusive coordination locks during sync
// windows and on-demand materialization of evicted files. These surface as
-// EAGAIN (errno -11) or EDEADLK from Node's fs calls. 50ms + 100ms covers the
-// common sub-200ms coordination windows without making transients observable.
+// EAGAIN (errno -11), EDEADLK, EBUSY, or EIO from Node's fs calls. EBUSY and
+// EIO are included because bird contention on busy iCloud paths (e.g. a large
+// file mid-upload or a coordination handoff) can surface either code, and
+// treating them as fatal would surface unnecessary errors to callers when a
+// single retry is sufficient. 50ms + 100ms covers the common sub-200ms
+// coordination windows without making transients observable.
// Exposed (not const) so tests can set it to `[0, 0]` to keep the retry path
// covered without paying the backoff sleep. (An empty array would still work
// — and run faster still — but it would disable the retry loop entirely,
@@ -46,7 +50,9 @@ export let TRANSIENT_RETRY_DELAYS_MS = [50, 100];
export function _setRetryDelaysForTest(delays) { TRANSIENT_RETRY_DELAYS_MS = delays; }
function isTransientFsError(err) {
- return !!err && (err.code === 'EAGAIN' || err.code === 'EDEADLK' || err.errno === -11);
+ if (!err) return false;
+ const { code, errno } = err;
+ return code === 'EAGAIN' || code === 'EDEADLK' || code === 'EBUSY' || code === 'EIO' || errno === -11;
}
/**
diff --git a/server/services/mortalLoomStore.test.js b/server/services/mortalLoomStore.test.js
index f80677808b..39891d32c8 100644
--- a/server/services/mortalLoomStore.test.js
+++ b/server/services/mortalLoomStore.test.js
@@ -321,6 +321,56 @@ describe('getStatus', () => {
});
});
+describe('readStore — EBUSY / EIO retry (bird daemon contention)', () => {
+ it('retries on EBUSY and succeeds on a later attempt', async () => {
+ const transient = Object.assign(new Error('EBUSY'), { code: 'EBUSY' });
+ readFileMock.mockRejectedValueOnce(transient);
+ readFileMock.mockResolvedValueOnce(JSON.stringify({ goals: [{ id: 'busy-recovered' }] }));
+
+ const result = await store.readStore();
+
+ expect(result).toEqual({ goals: [{ id: 'busy-recovered' }] });
+ expect(readFileMock).toHaveBeenCalledTimes(2);
+ expect(console.warn).not.toHaveBeenCalled();
+ });
+
+ it('retries on EIO and succeeds on a later attempt', async () => {
+ const transient = Object.assign(new Error('EIO'), { code: 'EIO' });
+ readFileMock.mockRejectedValueOnce(transient);
+ readFileMock.mockResolvedValueOnce(JSON.stringify({ goals: [{ id: 'eio-recovered' }] }));
+
+ const result = await store.readStore();
+
+ expect(result).toEqual({ goals: [{ id: 'eio-recovered' }] });
+ expect(readFileMock).toHaveBeenCalledTimes(2);
+ expect(console.warn).not.toHaveBeenCalled();
+ });
+
+ it('exhausts retries on persistent EBUSY (3 attempts total) and warns once', async () => {
+ const transient = Object.assign(new Error('EBUSY'), { code: 'EBUSY' });
+ readFileMock.mockRejectedValue(transient);
+
+ const result = await store.readStore();
+
+ expect(result).toBeNull();
+ expect(readFileMock).toHaveBeenCalledTimes(3);
+ expect(console.warn).toHaveBeenCalledTimes(1);
+ expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('MortalLoom store unavailable (EBUSY)'));
+ });
+
+ it('exhausts retries on persistent EIO (3 attempts total) and warns once', async () => {
+ const transient = Object.assign(new Error('EIO'), { code: 'EIO' });
+ readFileMock.mockRejectedValue(transient);
+
+ const result = await store.readStore();
+
+ expect(result).toBeNull();
+ expect(readFileMock).toHaveBeenCalledTimes(3);
+ expect(console.warn).toHaveBeenCalledTimes(1);
+ expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('MortalLoom store unavailable (EIO)'));
+ });
+});
+
describe('readStore — EAGAIN retry', () => {
it('retries on transient EAGAIN and succeeds when a later attempt resolves', async () => {
// First attempt: EAGAIN (iCloud coordination lock). Second attempt: success.