Skip to content

Commit de018d5

Browse files
kathiekiwiTrigger.dev RepoOps
authored andcommitted
fix(webapp): log the cause of retryable alert delivery failures
Log the underlying cause of retryable alert delivery failures to make debugging easier. Mono-RevId: 912e9445b97f1d7a322e66e947fd9c4ceab06097
1 parent ec17038 commit de018d5

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎apps/webapp/app/v3/services/alerts/delivery/deliverAlertEvent.server.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ export async function deliverAlertEvent(
232232
}
233233

234234
const { claimId } = claim;
235+
let channelType: ChannelInfo["type"] | undefined;
236+
let channelId: string | undefined;
235237

236238
try {
237239
if (delivery.notifier.type === "chat") {
@@ -259,6 +261,9 @@ export async function deliverAlertEvent(
259261
continue;
260262
}
261263

264+
channelType = channel.type;
265+
channelId = channel.id;
266+
262267
if (!channel.enabled) {
263268
await markDeliveryFailed(db, {
264269
id: delivery.id,
@@ -272,6 +277,14 @@ export async function deliverAlertEvent(
272277
const rateLimitResult = await checkRateLimit(channel.id);
273278
if (rateLimitResult && !rateLimitResult.allowed) {
274279
await releaseDelivery(db, { id: delivery.id, eventAt, claimId, refundAttempt: true });
280+
logger.warn("[deliverAlertEvent] Delivery rate limited", {
281+
deliveryId: delivery.id,
282+
eventId,
283+
alertId: alert.id,
284+
channelType,
285+
channelId,
286+
attempts: claim.delivery.attempts,
287+
});
275288
retryableErrors.push(new Error("rate_limited"));
276289
continue;
277290
}
@@ -326,6 +339,15 @@ export async function deliverAlertEvent(
326339
}
327340

328341
await releaseDelivery(db, { id: delivery.id, eventAt, claimId });
342+
logger.warn("[deliverAlertEvent] Delivery failed, will retry", {
343+
deliveryId: delivery.id,
344+
eventId,
345+
alertId: alert.id,
346+
channelType,
347+
channelId,
348+
attempts: claim.delivery.attempts,
349+
error,
350+
});
329351
retryableErrors.push(error);
330352
}
331353
}

0 commit comments

Comments
 (0)