Fixes #127626: Add try/catch around JSON.parse

This commit is contained in:
Alex Dima
2021-06-30 13:36:33 +02:00
parent 5344df3d43
commit 7e05d8c9d9

View File

@@ -177,7 +177,13 @@ async function readLockfileContents(logService: ILogService, filename: string):
return null;
}
return JSON.parse(String(contents));
try {
return JSON.parse(String(contents));
} catch (err) {
// cannot parse the file
logService.error(err);
return null;
}
}
/**