diff --git a/src/app-gocardless/services/gocardless-service.js b/src/app-gocardless/services/gocardless-service.js index 7e67330ce..e7b59a322 100644 --- a/src/app-gocardless/services/gocardless-service.js +++ b/src/app-gocardless/services/gocardless-service.js @@ -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) { diff --git a/upcoming-release-notes/278.md b/upcoming-release-notes/278.md new file mode 100644 index 000000000..4c0ad647e --- /dev/null +++ b/upcoming-release-notes/278.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MatissJanis] +--- + +Fix: gocardless bank sync not working as expected after last migration PR merge