When you call readJSON() on this line, there is a chance that an exception will be thrown, since JSON.parse() is called under-the-hood.
JSON.parse() calls should be wrapped in a try-catch block in case the string can't be parsed as JSON. This can happen if another program creates/modifies the cache file, or if the node script using flat-cache crashes in the middle of a write.
When you call
readJSON()
on this line, there is a chance that an exception will be thrown, sinceJSON.parse()
is called under-the-hood.JSON.parse()
calls should be wrapped in atry-catch
block in case the string can't be parsed as JSON. This can happen if another program creates/modifies the cache file, or if the node script usingflat-cache
crashes in the middle of a write.This issue is currently affecting ESLint (https://github.com/eslint/eslint/issues/7748) and standard (https://github.com/feross/standard/issues/673). More details in the linked issues.