[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', () => { resp.on('end', () => {
logger.debug('resp.on.end', {data, url}); logger.debug('resp.on.end', {data, url});
if (data.length) { if (data.length) {
const respBody = JSON.parse(data); try {
if (respBody.status === 'OK') { const respBody = JSON.parse(data);
resolve(true); if (respBody.status === 'OK') {
return; resolve(true);
return;
}
} catch (e) {
logger.error('Cannot parse response')
} }
} }
resolve(false); resolve(false);