Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Catch crash file parsing errors
Browse files Browse the repository at this point in the history
Reviewed By: passy

Differential Revision: D38940908

fbshipit-source-id: 59f0669311093a4a9c24f570d7e63de0a51f9376
  • Loading branch information
aigoncharov authored and facebook-github-bot committed Aug 23, 2022
1 parent 5aff69d commit 9b58f52
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions desktop/flipper-server-core/src/devices/ios/iOSCrashUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ export function parsePathLegacy(content: string): string | null {
}

export function parsePathModern(content: string): string | null {
const lines = content.split('\n');
// Skip the first line of the .ips file as it is useless
const reportBodyString = lines.slice(1).join('\n');
const reportBody = JSON.parse(reportBodyString);
return reportBody.procPath;
try {
const lines = content.split('\n');
// Skip the first line of the .ips file as it is useless
const reportBodyString = lines.slice(1).join('\n');
const reportBody = JSON.parse(reportBodyString);
return reportBody.procPath;
} catch (e) {
console.warn('parsePathModern -> failed to parse crash file', e, content);
return null;
}
}

// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -127,12 +132,20 @@ export class iOSCrashWatcher extends DeviceListener {
!!checkFileExtensionLegacy,
)
) {
this.device.flipperServer.emit('device-crash', {
crash: checkFileExtensionLegacy
? parseIosCrashLegacy(data)
: parseIosCrashModern(data),
serial: this.device.serial,
});
try {
this.device.flipperServer.emit('device-crash', {
crash: checkFileExtensionLegacy
? parseIosCrashLegacy(data)
: parseIosCrashModern(data),
serial: this.device.serial,
});
} catch (e) {
console.error(
'iOSCrashWatcher.startListener -> failed to parse crash file',
e,
data,
);
}
}
});
});
Expand Down

0 comments on commit 9b58f52

Please sign in to comment.