From 25a76750a7dc0f6892bc43ced5a609e766ca6281 Mon Sep 17 00:00:00 2001 From: Bogdan Nechyporenko Date: Tue, 18 Mar 2025 20:55:31 +0100 Subject: [PATCH] Made "notification:send" action idempotent Signed-off-by: Bogdan Nechyporenko --- .changeset/tame-sloths-brake.md | 5 +++++ .../src/actions/sendNotification.ts | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changeset/tame-sloths-brake.md diff --git a/.changeset/tame-sloths-brake.md b/.changeset/tame-sloths-brake.md new file mode 100644 index 0000000000..eae1321175 --- /dev/null +++ b/.changeset/tame-sloths-brake.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-notifications': patch +--- + +Made "notification:send" action idempotent diff --git a/plugins/scaffolder-backend-module-notifications/src/actions/sendNotification.ts b/plugins/scaffolder-backend-module-notifications/src/actions/sendNotification.ts index 9646de0001..d1954dfd8c 100644 --- a/plugins/scaffolder-backend-module-notifications/src/actions/sendNotification.ts +++ b/plugins/scaffolder-backend-module-notifications/src/actions/sendNotification.ts @@ -133,9 +133,14 @@ export function createSendNotificationAction(options: { }; try { - await notifications.send({ - recipients: notificationRecipients, - payload, + await ctx.checkpoint({ + key: `send.notification.${payload.title}`, + fn: async () => { + await notifications.send({ + recipients: notificationRecipients, + payload, + }); + }, }); } catch (e) { ctx.logger.error(`Failed to send notification: ${e}`);