Skip to content

Commit 08cc01c

Browse files
committed
Treat a missing webhook as cleaned up when rolling back a failed registration write
1 parent a2746e8 commit 08cc01c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

packages/twenty-apps/public/fathom/src/logic-functions/utils/store-fathom-webhook-registration.util.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { type Fathom } from 'fathom-typescript';
22
import { kv } from 'twenty-sdk/logic-function';
33

44
import { type FathomWebhookRegistration } from 'src/logic-functions/types/fathom-webhook-registration.type';
5+
import { deleteStaleFathomWebhook } from 'src/logic-functions/utils/delete-stale-fathom-webhook.util';
6+
import { toErrorMessage } from 'src/logic-functions/utils/to-error-message.util';
57

68
export const storeFathomWebhookRegistration = async ({
79
fathomClient,
@@ -30,10 +32,13 @@ export const storeFathomWebhookRegistration = async ({
3032
// recorded can never be found again: undo it before the retry creates
3133
// a second one against the same destination.
3234
try {
33-
await fathomClient.deleteWebhook({ id: registration.webhookId });
34-
} catch {
35+
await deleteStaleFathomWebhook({
36+
fathomClient,
37+
webhookId: registration.webhookId,
38+
});
39+
} catch (deleteError) {
3540
console.error(
36-
`[fathom] leaked webhook ${registration.webhookId} for connected account ${connectedAccountId}`,
41+
`[fathom] leaked webhook ${registration.webhookId} for connected account ${connectedAccountId}: ${toErrorMessage(deleteError)}`,
3742
);
3843
}
3944

0 commit comments

Comments
 (0)