From 8a3433f52dd039f87f395d8d0dde43f92e669717 Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Wed, 15 Nov 2023 19:03:23 +0000 Subject: [PATCH 1/2] :bug: (gocardless) fix banksync - create singleton client --- .../services/gocardless-service.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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) { From 8d82d8b86c41c106532701b06888118527d38a33 Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Wed, 15 Nov 2023 19:06:44 +0000 Subject: [PATCH 2/2] Release notes --- upcoming-release-notes/278.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 upcoming-release-notes/278.md 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