From c1adb80870aff2c73321c9f05725236b8dac087a Mon Sep 17 00:00:00 2001 From: Adrian Smijulj Date: Fri, 8 Oct 2021 07:33:45 +0200 Subject: [PATCH] fix: wrap logs sending into a try...catch --- packages/handler-logs/src/index.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/handler-logs/src/index.ts b/packages/handler-logs/src/index.ts index d81e1fd9596..31f30b1c821 100644 --- a/packages/handler-logs/src/index.ts +++ b/packages/handler-logs/src/index.ts @@ -17,14 +17,19 @@ export default () => ({ async apply() { const url = process.env.WEBINY_LOGS_FORWARD_URL; if (logs.length && typeof url === "string" && url.startsWith("http")) { - await fetch(url, { - method: "POST", - headers: { - "Content-Type": "application/json", - "Bypass-Tunnel-Reminder": "1" - }, - body: JSON.stringify(logs) - }); + try { + const body = JSON.stringify(logs); + await fetch(url, { + body, + method: "POST", + headers: { + "Content-Type": "application/json", + "Bypass-Tunnel-Reminder": "1" + } + }); + } catch { + // Do nothing. + } } logs.length = 0; }