mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-21 11:49:32 -05:00
fix(webhooks): ignore dispatcher cleanup failures
This commit is contained in:
@@ -858,6 +858,29 @@ describe("processResponsePipelineJob", () => {
|
||||
expect(mockDispatcherDestroy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("logs dispatcher cleanup failures without failing a successful webhook delivery", async () => {
|
||||
const cleanupError = new Error("destroy failed");
|
||||
mockPrismaWebhookFindMany.mockResolvedValue([
|
||||
{
|
||||
id: "webhook_123",
|
||||
secret: null,
|
||||
url: "https://example.com/webhook",
|
||||
},
|
||||
]);
|
||||
mockDispatcherDestroy.mockRejectedValue(cleanupError);
|
||||
|
||||
await expect(processResponsePipelineJob(baseData, baseContext)).resolves.toBeUndefined();
|
||||
|
||||
expect(mockLoggerWarn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
err: cleanupError,
|
||||
webhookId: "webhook_123",
|
||||
webhookUrl: "https://example.com/webhook",
|
||||
}),
|
||||
"Response pipeline webhook dispatcher cleanup failed"
|
||||
);
|
||||
});
|
||||
|
||||
test("destroys the pinned dispatcher when the webhook fetch throws", async () => {
|
||||
mockPrismaWebhookFindMany.mockResolvedValue([
|
||||
{
|
||||
|
||||
@@ -254,7 +254,19 @@ const createWebhookDeliveryTask = async ({
|
||||
throw new Error(`Webhook delivery failed with status ${response.status}`);
|
||||
}
|
||||
} finally {
|
||||
await dispatcher?.destroy();
|
||||
try {
|
||||
await dispatcher?.destroy();
|
||||
} catch (cleanupError) {
|
||||
logger.warn(
|
||||
{
|
||||
...logContext,
|
||||
err: cleanupError,
|
||||
webhookId: webhook.id,
|
||||
webhookUrl: webhook.url,
|
||||
},
|
||||
"Response pipeline webhook dispatcher cleanup failed"
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
|
||||
Reference in New Issue
Block a user