Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GoCD Slack feed handler to handle failures gracefully #776

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/brain/gocdSlackFeeds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
});

export async function handler(body: GoCDResponse) {
await Promise.all([
const promises = [
deployFeed.handle(body),
devinfraFeed.handle(body),
snsSaaSFeed.handle(body),
Expand All @@ -292,7 +292,14 @@
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);

Check warning on line 300 in src/brain/gocdSlackFeeds/index.ts

View check run for this annotation

Codecov / codecov/patch

src/brain/gocdSlackFeeds/index.ts#L300

Added line #L300 was not covered by tests
}
});
}

export async function gocdSlackFeeds() {
Expand Down
Loading