Skip to content

A local-first personal finance app

[AI] Explain SimpleFIN outages instead of a generic internal error (#9299)

Aryan Deshmukh644077279e8f
diff --git a/packages/desktop-client/src/accounts/syncStatus.test.ts b/packages/desktop-client/src/accounts/syncStatus.test.ts
index 8be7ec34ec..b5a539a979 100644
--- a/packages/desktop-client/src/accounts/syncStatus.test.ts
+++ b/packages/desktop-client/src/accounts/syncStatus.test.ts
@@ -17,6 +17,7 @@ describe('syncStatus', () => {
expect(isAccountFailedSync(makeAccount('reauth-required'))).toBe(true);
expect(isAccountFailedSync(makeAccount('rate-limit-exceeded'))).toBe(true);
expect(isAccountFailedSync(makeAccount('timed-out'))).toBe(true);
+ expect(isAccountFailedSync(makeAccount('server-down'))).toBe(true);
expect(isAccountFailedSync(makeAccount('account-missing'))).toBe(true);
expect(isAccountFailedSync(makeAccount('not-configured'))).toBe(true);
expect(isAccountFailedSync(makeAccount('pending'))).toBe(false);
@@ -48,6 +49,10 @@ describe('syncStatus', () => {
type: 'TIMED_OUT',
code: 'TIMED_OUT',
});
+ expect(getFailedSyncError(makeAccount('server-down'))).toEqual({
+ type: 'SERVER_DOWN',
+ code: 'SERVER_DOWN',
+ });
expect(getFailedSyncError(makeAccount('account-missing'))).toEqual({
type: 'ACCOUNT_MISSING',
code: 'ACCOUNT_MISSING',
diff --git a/packages/desktop-client/src/accounts/syncStatus.ts b/packages/desktop-client/src/accounts/syncStatus.ts
index 770509fd02..151c785e0c 100644
--- a/packages/desktop-client/src/accounts/syncStatus.ts
+++ b/packages/desktop-client/src/accounts/syncStatus.ts
@@ -30,6 +30,8 @@ export function getFailedSyncError(
return { type: 'RATE_LIMIT_EXCEEDED', code: 'RATE_LIMIT_EXCEEDED' };
case 'timed-out':
return { type: 'TIMED_OUT', code: 'TIMED_OUT' };
+ case 'server-down':
+ return { type: 'SERVER_DOWN', code: 'SERVER_DOWN' };
case 'account-missing':
return { type: 'ACCOUNT_MISSING', code: 'ACCOUNT_MISSING' };
case 'not-configured':
diff --git a/packages/desktop-client/src/components/accounts/AccountSyncCheck.test.tsx b/packages/desktop-client/src/components/accounts/AccountSyncCheck.test.tsx
index 89d7d125f2..31f07233da 100644
--- a/packages/desktop-client/src/components/accounts/AccountSyncCheck.test.tsx
+++ b/packages/desktop-client/src/components/accounts/AccountSyncCheck.test.tsx
@@ -150,6 +150,31 @@ describe('AccountSyncCheck', () => {
).toBeInTheDocument();
});
+ it('explains that SimpleFIN is unreachable instead of a generic internal error', async () => {
+ vi.mocked(useFailedAccounts).mockReturnValue(
+ new Map([['acc-1', { type: 'SERVER_DOWN', code: 'SERVER_DOWN' }]]),
+ );
+
+ render(
+ <TestProviders>
+ <AccountSyncCheck />
+ </TestProviders>,
+ );
+
+ await userEvent.click(
+ screen.getByText(
+ "This account is experiencing connection problems. Let's fix it.",
+ ),
+ );
+
+ expect(
+ screen.getByText(
+ 'SimpleFIN could not be reached or is down for maintenance. Please try again later.',
+ ),
+ ).toBeInTheDocument();
+ expect(screen.queryByText(/An internal error occurred/)).toBeNull();
+ });
+
it('hides Configure button and only shows Unlink account for non-admin users', async () => {
vi.mocked(useCurrentAccess).mockReturnValue({
isAdmin: false,
diff --git a/packages/desktop-client/src/components/accounts/AccountSyncCheck.tsx b/packages/desktop-client/src/components/accounts/AccountSyncCheck.tsx
index 92ec7176cd..1f6b047413 100644
--- a/packages/desktop-client/src/components/accounts/AccountSyncCheck.tsx
+++ b/packages/desktop-client/src/components/accounts/AccountSyncCheck.tsx
@@ -57,6 +57,11 @@ function useErrorMessage() {
case 'TIMED_OUT':
return t('The request timed out. Please try again later.');
+ case 'SERVER_DOWN':
+ return t(
+ 'SimpleFIN could not be reached or is down for maintenance. Please try again later.',
+ );
+
case 'INVALID_ACCESS_TOKEN':
return t(
'Your SimpleFIN Access Token is no longer valid. Please reset and generate a new token.',
diff --git a/packages/loot-core/src/server/accounts/app-bank-sync.test.ts b/packages/loot-core/src/server/accounts/app-bank-sync.test.ts
index a13a142cc7..8f08ebec45 100644
--- a/packages/loot-core/src/server/accounts/app-bank-sync.test.ts
+++ b/packages/loot-core/src/server/accounts/app-bank-sync.test.ts
@@ -252,6 +252,33 @@ describe('accountsBankSync', () => {
expect(account!.bank_sync_status).toBe('timed-out');
});
+ it('persists server-down status when the bank sync provider is down', async () => {
+ insertBank({ id: 'bank1', bank_id: 'sfin-bank', name: 'SimpleFin' });
+ await db.insertAccount({
+ id: 'acct1',
+ name: 'Checking',
+ bank: 'bank1',
+ account_id: 'ext-1',
+ account_sync_source: 'simpleFin',
+ });
+
+ vi.mocked(bankSync.syncAccount).mockRejectedValue({
+ type: 'BankSyncError',
+ reason: 'There was an error communicating with SimpleFIN.',
+ category: 'SERVER_DOWN',
+ code: 'SERVER_DOWN',
+ message: 'There was an error communicating with SimpleFIN.',
+ });
+
+ await accountsBankSyncHandler({ ids: ['acct1'] });
+
+ const account = await db.first<db.DbAccount>(
+ 'SELECT * FROM accounts WHERE id = ?',
+ ['acct1'],
+ );
+ expect(account!.bank_sync_status).toBe('server-down');
+ });
+
it('persists failed status after an operational sync error', async () => {
insertBank({ id: 'bank1', bank_id: 'gc-bank', name: 'GoCardless' });
await db.insertAccount({
diff --git a/packages/loot-core/src/server/accounts/app.ts b/packages/loot-core/src/server/accounts/app.ts
index c68f3d21c8..42be01eaa8 100644
--- a/packages/loot-core/src/server/accounts/app.ts
+++ b/packages/loot-core/src/server/accounts/app.ts
@@ -1419,6 +1419,10 @@ function getBankSyncStatusFromError(
return 'timed-out';
}
+ if (err.category === 'SERVER_DOWN') {
+ return 'server-down';
+ }
+
if (err.category === 'ACCOUNT_MISSING') {
return 'account-missing';
}
diff --git a/packages/loot-core/src/server/db/types/index.ts b/packages/loot-core/src/server/db/types/index.ts
index ee0000a4ea..cff2c7ad96 100644
--- a/packages/loot-core/src/server/db/types/index.ts
+++ b/packages/loot-core/src/server/db/types/index.ts
@@ -33,6 +33,7 @@ export type DbAccount = {
| 'attention-required'
| 'rate-limit-exceeded'
| 'timed-out'
+ | 'server-down'
| 'account-missing'
| 'not-configured'
| null;
diff --git a/packages/loot-core/src/types/models/account.ts b/packages/loot-core/src/types/models/account.ts
index 1896f5efb4..06a7e98222 100644
--- a/packages/loot-core/src/types/models/account.ts
+++ b/packages/loot-core/src/types/models/account.ts
@@ -37,5 +37,6 @@ export type BankSyncStatus =
| 'attention-required'
| 'rate-limit-exceeded'
| 'timed-out'
+ | 'server-down'
| 'account-missing'
| 'not-configured';
diff --git a/upcoming-release-notes/simplefin-server-down-message.md b/upcoming-release-notes/simplefin-server-down-message.md
new file mode 100644
index 0000000000..d938e3e420
--- /dev/null
+++ b/upcoming-release-notes/simplefin-server-down-message.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [A-RYAN-1]
+---
+
+Show a clear message when SimpleFIN cannot be reached or is down for maintenance, instead of a generic internal error