[MM-56882] Fix a potential crash in diagnostics (#2960)

This commit is contained in:
Devin Binnie 2024-02-16 12:27:30 -05:00 committed by GitHub
parent ad3da23863
commit 405403ca99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -72,10 +72,14 @@ export async function isOnline(logger: ElectronLog = log, url = IS_ONLINE_ENDPOI
resp.on('end', () => {
logger.debug('resp.on.end', {data, url});
if (data.length) {
const respBody = JSON.parse(data);
if (respBody.status === 'OK') {
resolve(true);
return;
try {
const respBody = JSON.parse(data);
if (respBody.status === 'OK') {
resolve(true);
return;
}
} catch (e) {
logger.error('Cannot parse response')
}
}
resolve(false);