From d003021486f29d320ca85894fac2477ef4adeda1 Mon Sep 17 00:00:00 2001 From: Ian Woodard <17186604+IanWoodard@users.noreply.github.com> Date: Wed, 3 Apr 2024 08:05:44 -0700 Subject: [PATCH] Refactor GoCD Slack feed handler to handle failures gracefully --- src/brain/gocdSlackFeeds/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/brain/gocdSlackFeeds/index.ts b/src/brain/gocdSlackFeeds/index.ts index 2d6d98f7..3c95e127 100644 --- a/src/brain/gocdSlackFeeds/index.ts +++ b/src/brain/gocdSlackFeeds/index.ts @@ -283,7 +283,7 @@ const engineeringFeed = new DeployFeed({ }); export async function handler(body: GoCDResponse) { - await Promise.all([ + const promises = [ deployFeed.handle(body), devinfraFeed.handle(body), snsSaaSFeed.handle(body), @@ -292,7 +292,14 @@ export async function handler(body: GoCDResponse) { engineeringFeed.handle(body), snsS4SK8sFeed.handle(body), snsSaaSK8sFeed.handle(body), - ]); + ]; + // Don't fail the entire handler if one of the feeds fails + const results = await Promise.allSettled(promises); + results.forEach((result) => { + if (result.status === 'rejected' && result.reason instanceof Error) { + Sentry.captureException(result.reason); + } + }); } export async function gocdSlackFeeds() {