Skip to content

Commit

Permalink
add try catch to log json parsing (#4491)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Apr 2, 2024
1 parent 28f6754 commit 08df062
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,17 @@ export const useLogs = ({
}
const jsonData = evt.data.trim().split("\n");
const newLogs = jsonData.map((data: string) => {
const parsedLogData = z
.record(z.unknown())
.safeParse(JSON.parse(data));
if (!parsedLogData.success) {
try {
const parsedLogData = z
.record(z.unknown())
.safeParse(JSON.parse(data));
if (!parsedLogData.success) {
return {};
}
return parsedLogData.data;
} catch (err) {
return {};
}

return parsedLogData.data;
});
const newLogsParsed = parseLogsFromAgent(newLogs);

Expand Down

0 comments on commit 08df062

Please sign in to comment.