Skip to content

Commit

Permalink
fix(desktop): don't error out when collecting log files during
Browse files Browse the repository at this point in the history
troubleshooting, it's okay if we can't find them
  • Loading branch information
pascalbreuninger committed Jan 28, 2025
1 parent 0af0e58 commit 981c703
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions desktop/src/lib/useStoreTroubleshoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ export function useStoreTroubleshoot() {

const zip = new JSZip()

const logFilesData = await Promise.all(
unwrappedLogFiles.map(async ([src, target]) => {
const data = await client.readFile(src)

return { fileName: target, data }
})
)
const logFilesData = (
await Promise.all(
unwrappedLogFiles.map(async ([src, target]) => {
try {
const data = await client.readFile(src)
return { fileName: target, data }
} catch (err) {
// ignore missing log files and continue
return null
}
})
)
).filter((d): d is Exclude<typeof d, null> => d != null)

logFilesData.forEach((logFile) => {
zip.file(logFile.fileName, logFile.data)
Expand All @@ -67,7 +73,7 @@ export function useStoreTroubleshoot() {
},
onError(error) {
toast({
title: `Failed to save logs: ${error}`,
title: `Failed to save zip: ${error}`,
status: "error",
isClosable: true,
duration: 30_000, // 30 sec
Expand Down

0 comments on commit 981c703

Please sign in to comment.