Skip to content

Commit

Permalink
🐛 (gocardless) fix banksync - create singleton client (actualbudget#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored and MMichotte committed Sep 9, 2024
1 parent a2d534b commit ce3d5c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/app-gocardless/services/gocardless-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,22 @@ import { SecretName, secretsService } from '../../services/secrets-service.js';

const GoCardlessClient = nordigenNode.default;

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

const getGocardlessClient = () => {
const secrets = {
secretId: secretsService.get(SecretName.nordigen_secretId),
secretKey: secretsService.get(SecretName.nordigen_secretKey),
});
};

const hash = JSON.stringify(secrets);

if (!clients.has(hash)) {
clients.set(hash, new GoCardlessClient(secrets));
}

return clients.get(hash);
};

export const handleGoCardlessError = (response) => {
switch (response.status_code) {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/278.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---

Fix: gocardless bank sync not working as expected after last migration PR merge

0 comments on commit ce3d5c9

Please sign in to comment.