feat: Reduce webhook response payload to status-only (#25072)

* feat: reduce webhook payload

* Update packages/trpc/server/routers/viewer/webhook/testTrigger.handler.ts

Co-authored-by: Volnei Munhoz <[email protected]>

---------

Co-authored-by: Volnei Munhoz <[email protected]>
This commit is contained in:
Hariom BalharaandVolnei Munhoz authored and GitHub committed 2025-11-11 17:18:05 +00:00
1 parent d50a7b9d00
commit 1325e8488f
4 files changed
+9 -12

No files matched your search

@@ -69,8 +69,12 @@ export default function WebhookTestDisclosure() {
</div>
<div className="bg-muted border-subtle rounded-b-lg border border-t-0 p-4 font-mono text-[13px] leading-4">
{!mutation.data && <p>{t("no_data_yet")}</p>}
{mutation.status === "success" && (
<div className="overflow-x-auto">{JSON.stringify(mutation.data, null, 4)}</div>
{mutation.status === "success" && mutation.data && (
<div className="space-y-2">
<div>
<span className="text-subtle">{t("status")}:</span> <span className="text-emphasis">{mutation.data.status}</span>
</div>
</div>
)}
</div>
</div>
@@ -64,6 +64,8 @@ export async function handleWebhookScheduledTriggers(prisma: PrismaClient) {
method: "POST",
body: job.payload,
headers,
// Avoid following redirect
redirect: "manual"
}).catch((error) => {
console.error(`Webhook trigger for subscriber url ${job.subscriberUrl} failed with error: ${error}`);
})
@@ -305,16 +305,9 @@ const _sendPayload = async (
body,
});
const text = await response.text();
return {
ok: response.ok,
status: response.status,
...(text
? {
message: text,
}
: {}),
};
};
@@ -43,12 +43,10 @@ export const testTriggerHandler = async ({ ctx: _ctx, input }: TestTriggerOption
try {
const webhook = { subscriberUrl: url, appId: null, payloadTemplate };
return await sendPayload(secret, type, new Date().toISOString(), webhook, data);
} catch (_err) {
const error = getErrorFromUnknown(_err);
} catch {
return {
ok: false,
status: 500,
message: error.message,
};
}
};