Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: GoCardless token expires before completion on long imports #3590

Open
2 tasks done
AntwaneB opened this issue Oct 6, 2024 · 1 comment
Open
2 tasks done

[Bug]: GoCardless token expires before completion on long imports #3590

AntwaneB opened this issue Oct 6, 2024 · 1 comment
Labels
bank sync Related to automatic bank syncing bug Something isn't working help wanted Extra attention is needed server

Comments

@AntwaneB
Copy link

AntwaneB commented Oct 6, 2024

Verified issue does not already exist?

  • I have searched and found no existing issue
  • I will be providing steps how to reproduce the bug (in most cases this will also mean uploading a demo budget file)

What happened?

Hello,

When importing accounts with a long history (390 days) and a lot of transactions, the GoCardless JWT token actually expires before the sync completes, but isn't refreshed in all the operations that make API calls to GoCardless, leading to an exception in the logs and the UI crashing (and the account never being imported).

Here's the relevant part of the stacktrace:

2024-10-06T21:43:11.762Z info: POST 200 /sync/sync
Error /gocardless/get-accounts InvalidGoCardlessTokenError: Token is invalid or expired
    at handleGoCardlessError (file:///app/src/app-gocardless/services/gocardless-service.js:46:13)
    at Object.getDetailedAccount (file:///app/src/app-gocardless/services/gocardless-service.js:413:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///app/src/app-gocardless/services/gocardless-service.js:152:25
    at async Promise.all (index 0)
    at async Object.getRequisitionWithAccounts (file:///app/src/app-gocardless/services/gocardless-service.js:150:30)
    at async file:///app/src/app-gocardless/app-gocardless.js:68:9 {

I imagine this can crash in multiple places, but we can see for example in the getDetailedAccount call, it doesn't call setToken.

I don't see any downsides to calling setToken before each API call (especially if the expiration time is cached so it doesn't need to be decoded every time), so that should fix the issue, unfortunately I don't have the infrastructure setup to test the fix myself.

Thanks.

Where are you hosting Actual?

Docker

What browsers are you seeing the problem on?

Any

Operating System

Any

@AntwaneB AntwaneB added the bug Something isn't working label Oct 6, 2024
@MatissJanis MatissJanis added help wanted Extra attention is needed bank sync Related to automatic bank syncing server labels Oct 8, 2024
@AntwaneB
Copy link
Author

AntwaneB commented Oct 12, 2024

Quick update: I tried my proposed fix locally and it unfortunately does not address the issue. The exact same error happens in the same way.

I was able to validate that the token expiration date was indeed matching the time at which I got the stacktrace, and this makes me think that the assumption that the GoCardless API tokens last 24 hours is wrong (which I don't blame you for as their node client has the same comment in their example...).

The reason for this is that I had started my server (and even setup the GoCardless API keys) only a few hours before the sync failed, so it would make no sense that the token expired that quickly if it lasted 24 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bank sync Related to automatic bank syncing bug Something isn't working help wanted Extra attention is needed server
Projects
None yet
Development

No branches or pull requests

2 participants