Skip to content

A local-first personal finance app

Return GoCardless rate limit information on error (#509)

Matt Fiddaman645958bbeb25
diff --git a/src/app-gocardless/app-gocardless.js b/src/app-gocardless/app-gocardless.js
index cabeffcd62..b076a91b5b 100644
--- a/src/app-gocardless/app-gocardless.js
+++ b/src/app-gocardless/app-gocardless.js
@@ -201,8 +201,19 @@ app.post(
});
}
} catch (error) {
+ const headers = error.details?.response?.headers ?? {};
+
+ const rateLimitHeaders = Object.fromEntries(
+ Object.entries(headers).filter(([key]) =>
+ key.startsWith('http_x_ratelimit'),
+ ),
+ );
+
const sendErrorResponse = (data) =>
- res.send({ status: 'ok', data: { ...data, details: error.details } });
+ res.send({
+ status: 'ok',
+ data: { ...data, details: error.details, rateLimitHeaders },
+ });
switch (true) {
case error instanceof RequisitionNotLinked:
diff --git a/upcoming-release-notes/509.md b/upcoming-release-notes/509.md
new file mode 100644
index 0000000000..91e2afe471
--- /dev/null
+++ b/upcoming-release-notes/509.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [matt-fidd]
+---
+
+Add more logging for GoCardless rate limit information