Skip to content

Commit 857e734

Browse files
fix(web): treat session profile Discord delivery as best-effort
Co-authored-by: Richie McIlroy <richiemcilroy@users.noreply.github.com>
1 parent abc3e6b commit 857e734

1 file changed

Lines changed: 26 additions & 14 deletions

File tree

  • apps/web/app/api/desktop/[...route]

apps/web/app/api/desktop/[...route]/root.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -610,22 +610,34 @@ app.post(
610610
? `${header.slice(0, DISCORD_MESSAGE_MAX_LENGTH - 1)}…`
611611
: header;
612612

613-
const response = await fetch(discordWebhookUrl, {
614-
method: "POST",
615-
headers: { "Content-Type": "application/json" },
616-
body: JSON.stringify({
617-
content,
618-
allowed_mentions: { parse: [] },
619-
}),
620-
});
621-
622-
if (!response.ok) {
623-
throw new Error(
624-
`Failed to send session profile to Discord: ${response.statusText}`,
613+
// Discord delivery is best-effort: the bundle is already in S3 and
614+
// the download URL is valid, so a webhook failure must not turn the
615+
// whole request into a 500 (which would make the client re-upload).
616+
try {
617+
const response = await fetch(discordWebhookUrl, {
618+
method: "POST",
619+
headers: { "Content-Type": "application/json" },
620+
body: JSON.stringify({
621+
content,
622+
allowed_mentions: { parse: [] },
623+
}),
624+
});
625+
626+
if (response.ok) {
627+
discordDelivered = true;
628+
} else {
629+
console.error(
630+
"Failed to send session profile to Discord:",
631+
response.status,
632+
await response.text(),
633+
);
634+
}
635+
} catch (discordError) {
636+
console.error(
637+
"Failed to send session profile to Discord:",
638+
discordError,
625639
);
626640
}
627-
628-
discordDelivered = true;
629641
}
630642

631643
return c.json({ success: true, downloadUrl, discordDelivered });

0 commit comments

Comments
 (0)