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

🐛 (gocardless) fix banksync - create singleton client #278

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

MatissJanis
Copy link
Member

#267 introduced a small regression: the client is re-created every time it is used. Obviously this causes some problems as the access tokens get reset very often..

Instead I am now using a singleton client that is mapped by the secrets. Meaning: when secrets change we will generate a new client.

Copy link

@toebbel toebbel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks for the quick support 🙏
I tested this branch on my fly instance and the bank sync is fixed :)

@@ -18,11 +18,22 @@ import { SecretName, secretsService } from '../../services/secrets-service.js';

const GoCardlessClient = nordigenNode.default;

const getGocardlessClient = () =>
new GoCardlessClient({
const clients = new Map();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can different budgets have different Nordigen secrets? I guess the Map makes sense here 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different budgets can have different secrets, but also the same budget might change its keys. So in that case too we also want to generate a new client.

Comment on lines +31 to +33
if (!clients.has(hash)) {
clients.set(hash, new GoCardlessClient(secrets));
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 nice!

@trafico-bot trafico-bot bot added ✅ Approved Pull Request has been approved and can be merged and removed 🔍 Ready for Review labels Nov 15, 2023
@MatissJanis MatissJanis merged commit e116d01 into master Nov 16, 2023
6 checks passed
@MatissJanis MatissJanis deleted the matiss/fix-banksync branch November 16, 2023 07:19
@trafico-bot trafico-bot bot added ✨ Merged Pull Request has been merged successfully and removed ✨ Merged Pull Request has been merged successfully ✅ Approved Pull Request has been approved and can be merged labels Nov 16, 2023
MMichotte pushed a commit to MMichotte/actual-server that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants