swyphcosmo / vscode-spellchecker

Spell check extension for Visual Studio Code
MIT License
16 stars 10 forks source link

VSCode crash with Facebook auth token string #5

Closed albertogasparin closed 8 years ago

albertogasparin commented 8 years ago

I have a .env file with several of tokens in it. Everything was fine until I added a FB token like:

FB_AUTH_TOKEN=EAAPKZCriJaEABNMWhdZAZCKrNsS9AJ8cX1Y1wyVLfGvMIwpLKlmw0Ox9vNoSkMCqwptkb0Oj9QyyA0lG0zflySEdiN1TiNpHSqPXZCp9RVJZryv7LzjZAEOXGecmo5YbgHZAqZAt07VrE3nlPZaeYGxLnZA32KYXZAWrCZD

Now, every time I preview that file in VSCode it end up crashing after a bit. Uninstalling your extension restores VSCode stability. I have no other extension parsing the .env file.

swyphcosmo commented 8 years ago

Great catch! The issue turned out to be an issue with how the hunspell-spellchecker tries to build suggestions to the error. The authentication token you provided is 168 characters long. The first step is to transpose adjacent characters. Then, it creates permutations of the word by placing every other letter of the alphabet into each character slot. For a word of 168 characters, this list grows until the node has consumed all of the system memory. This is the cause of the crash.

I've created a fix for this to limit the word suggestions to words shorter than 50 characters (the longest word in the English dictionary is 45 characters). I will also add the ability to ignore certain file extensions. This would let you remove .env files from being checked by the extension.

I'll close this issue once a new version has been published.

swyphcosmo commented 8 years ago

Version 1.1.6 has been published. I'm not sure how to force vscode to update the extension list. You might need to uninstall the extension, and then reinstall it.

albertogasparin commented 8 years ago

Amazing! Thanks a lot, new version worked like a charm 👍