[Bug]: API runBankSync fails for all banks if one bank fails #2132

Closed
opened 2026-02-28 20:04:17 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @derekantrican on GitHub (May 16, 2025).

Verified issue does not already exist?

  • I have searched and found no existing issue

What happened?

I'm using the "sync-banks" script in actual-helpers to keep my accounts up to date. The script is very short so I'll copy it here:

// Script to run all bank syncs
// Useful for running bank syncs on a daily/weekly schedule
const { closeBudget, openBudget } = require('./utils');
const api = require('@actual-app/api');

(async () => {
  await openBudget();

  console.log("syncing banks...");
  await api.runBankSync();

  await closeBudget();
})();

I have 13 accounts added to Actual Budget via SimpleFIN and I use this script to keep them up to date. One of the accounts (treasurydirect) is notorious for requiring re-auth often, so it often fails to sync. However, this now prevents sync-banks from running successfully at all just because this one account fails to sync:

C:\Users\derek\Desktop\actual-budget-server\actual-helpers>node sync-banks.js
connect
open file
Loaded spreadsheet from cache (6270 items)
Syncing since 2025-05-15T03:06:12.529Z-0000-89d2e5b1d7f583e5 76 (attempt: 0)
Got messages from server 2
syncing banks...
Bank Sync operation for all SimpleFin accounts
  Pulling transactions from SimpleFin
  Response: {
    ...
  }
  Performing transaction reconciliation
  Performing transaction reconciliation matching
  ...
Unhandled Rejection at: Promise Promise {
  <rejected> Error: Failed syncing account “TreasuryDirect (I bonds).”
      at handlers.api/bank-sync (C:\Users\derek\Desktop\actual-budget-server\actual-helpers\node_modules\@actual-app\api\dist\app\bundle.api.js:87986:27)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
} reason: Error: Failed syncing account “TreasuryDirect (I bonds).”
    at handlers.api/bank-sync (C:\Users\derek\Desktop\actual-budget-server\actual-helpers\node_modules\@actual-app\api\dist\app\bundle.api.js:87986:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Error: Failed syncing account “TreasuryDirect (I bonds).”
    at handlers.api/bank-sync (C:\Users\derek\Desktop\actual-budget-server\actual-helpers\node_modules\@actual-app\api\dist\app\bundle.api.js:87986:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

I believe this is a problem with how the API method runBankSync works since actual-helpers' sync-banks is not doing anything "per bank".

How can we reproduce the issue?

Repro steps provided above

Where are you hosting Actual?

None

What browsers are you seeing the problem on?

No response

Operating System

None

Originally created by @derekantrican on GitHub (May 16, 2025). ### Verified issue does not already exist? - [x] I have searched and found no existing issue ### What happened? I'm using the ["sync-banks" script in actual-helpers](https://github.com/psybers/actual-helpers/blob/main/sync-banks.js) to keep my accounts up to date. The script is very short so I'll copy it here: ```js // Script to run all bank syncs // Useful for running bank syncs on a daily/weekly schedule const { closeBudget, openBudget } = require('./utils'); const api = require('@actual-app/api'); (async () => { await openBudget(); console.log("syncing banks..."); await api.runBankSync(); await closeBudget(); })(); ``` I have 13 accounts added to Actual Budget via SimpleFIN and I use this script to keep them up to date. One of the accounts (treasurydirect) is notorious for requiring re-auth often, so it often fails to sync. However, this now prevents sync-banks from running successfully at all just because this one account fails to sync: ``` C:\Users\derek\Desktop\actual-budget-server\actual-helpers>node sync-banks.js connect open file Loaded spreadsheet from cache (6270 items) Syncing since 2025-05-15T03:06:12.529Z-0000-89d2e5b1d7f583e5 76 (attempt: 0) Got messages from server 2 syncing banks... Bank Sync operation for all SimpleFin accounts Pulling transactions from SimpleFin Response: { ... } Performing transaction reconciliation Performing transaction reconciliation matching ... Unhandled Rejection at: Promise Promise { <rejected> Error: Failed syncing account “TreasuryDirect (I bonds).” at handlers.api/bank-sync (C:\Users\derek\Desktop\actual-budget-server\actual-helpers\node_modules\@actual-app\api\dist\app\bundle.api.js:87986:27) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) } reason: Error: Failed syncing account “TreasuryDirect (I bonds).” at handlers.api/bank-sync (C:\Users\derek\Desktop\actual-budget-server\actual-helpers\node_modules\@actual-app\api\dist\app\bundle.api.js:87986:27) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) Error: Failed syncing account “TreasuryDirect (I bonds).” at handlers.api/bank-sync (C:\Users\derek\Desktop\actual-budget-server\actual-helpers\node_modules\@actual-app\api\dist\app\bundle.api.js:87986:27) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) ``` I believe this is a problem with how the API method `runBankSync` works since actual-helpers' sync-banks is not doing anything "per bank". ### How can we reproduce the issue? Repro steps provided above ### Where are you hosting Actual? None ### What browsers are you seeing the problem on? _No response_ ### Operating System None
GiteaMirror added the bank syncneeds infobugAPI labels 2026-02-28 20:04:17 -06:00
Author
Owner

@MatissJanis commented on GitHub (Jun 3, 2025):

👋 I'm not overly familiar with how SimpleFIN sync works in Actual, but I had a quick look nonetheless.

Judging from the code: we run a sync operation for all SimpleFin accounts. If one account fails - the error initially gets "shallowed" to allow the rest of the accounts to sync. Only at the end of the execution process does it throw the error finally. But at that point the sync for all the other accounts would have already been successful.

Are you seeing something else in your app? All the accounts failing sync if this one account causes problems?

@MatissJanis commented on GitHub (Jun 3, 2025): 👋 I'm not overly familiar with how SimpleFIN sync works in Actual, but I had a quick look nonetheless. Judging from the code: we run a sync operation for all SimpleFin accounts. If one account fails - [the error initially gets "shallowed"](https://github.com/actualbudget/actual/blob/790d35b5c932a437b766ef2a4d4f9b6b5f729a5b/packages/loot-core/src/server/accounts/app.ts#L1021:L1031) to allow the rest of the accounts to sync. Only at the [end of the execution process](https://github.com/actualbudget/actual/blob/790d35b5c932a437b766ef2a4d4f9b6b5f729a5b/packages/loot-core/src/server/api.ts#L286:L288) does it throw the error finally. But at that point the sync for all the other accounts would have already been successful. Are you seeing something else in your app? All the accounts failing sync if this one account causes problems?
Author
Owner

@derekantrican commented on GitHub (Jun 3, 2025):

After watching this more over the last ~3 weeks, I'm going to assume I saw something different. I definitely saw some failures to sync, but they later caught up. I'll close this as "Not Repro" for now

@derekantrican commented on GitHub (Jun 3, 2025): After watching this more over the last ~3 weeks, I'm going to assume I saw something different. I definitely saw some failures to sync, but they later caught up. I'll close this as "Not Repro" for now
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#2132