-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Conversation
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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.
if (!clients.has(hash)) { | ||
clients.set(hash, new GoCardlessClient(secrets)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 nice!
#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.