-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught exception when cache file contains invalid JSON #12
Comments
Hi @feross, thanks for reporting it, will take a look. |
royriojas
added a commit
that referenced
this issue
Dec 19, 2016
Fixes #12 Not sure under which situations a cache file might exist that does not contain a valid JSON structure, but just in case to cover the possibility of this happening a try catch block has been added If the cache is somehow not valid the cache will be discarded an a a new cache will be stored instead
royriojas
added a commit
that referenced
this issue
Dec 20, 2016
Fixes #12 Not sure under which situations a cache file might exist that does not contain a valid JSON structure, but just in case to cover the possibility of this happening a try catch block has been added If the cache is somehow not valid the cache will be discarded an a a new cache will be stored instead
Hi @feross, a new patch version was published, should fix the issue in Eslint. |
@royriojas Excellent, thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 (eslint/eslint#7748) and standard (standard/standard#673). More details in the linked issues.
The text was updated successfully, but these errors were encountered: