Skip to content

Commit

Permalink
fix: wrap logs sending into a try...catch
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Oct 8, 2021
1 parent 1f6e1b0 commit c1adb80
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/handler-logs/src/index.ts
Expand Up @@ -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;
}
Expand Down

0 comments on commit c1adb80

Please sign in to comment.