alefragnani / vscode-project-manager

Project Manager Extension for Visual Studio Code
GNU General Public License v3.0
1.87k stars 222 forks source link

[BUG] - Extension broken when json parse error occures #687

Closed poelzi closed 1 year ago

poelzi commented 1 year ago

When a unspecified json is broken, the extension does not load. It does not notify the user which file is broken and the extension does not save the json to a default location.

2023-05-15 19:55:31.889 [error] SyntaxError: Unexpected token n in JSON at position 5303401
    at JSON.parse (<anonymous>)
    at t.CustomProjectLocator.initializeCfg (/home/poelzi/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:87744)
    at new t.CustomProjectLocator (/home/poelzi/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:87045)
    at new t.Locators (/home/poelzi/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:91629)
    at e.activate (/home/poelzi/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:166862)
    at Function._callActivateOptional (/nix/store/v2m6hrkvpgj19zp8wzf6s2g9h8fa79yx-vscode-1.73.1/lib/vscode/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:17678)
    at Function._callActivate (/nix/store/v2m6hrkvpgj19zp8wzf6s2g9h8fa79yx-vscode-1.73.1/lib/vscode/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:17338)
    at /nix/store/v2m6hrkvpgj19zp8wzf6s2g9h8fa79yx-vscode-1.73.1/lib/vscode/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:15133
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at w._activate (/nix/store/v2m6hrkvpgj19zp8wzf6s2g9h8fa79yx-vscode-1.73.1/lib/vscode/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:90:8304)
    at w._waitForDepsThenActivate (/nix/store/v2m6hrkvpgj19zp8wzf6s2g9h8fa79yx-vscode-1.73.1/lib/vscode/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:90:8246)
    at w._initialize (/nix/store/v2m6hrkvpgj19zp8wzf6s2g9h8fa79yx-vscode-1.73.1/lib/vscode/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:90:7610)

Environment/version

poelzi commented 1 year ago

Seems that, if any cache json is corrupted, like projects_cache_any.json the extension fails to load

alefragnani commented 1 year ago

Hi @poelzi ,

Nice catch! It is not properly handling corrupted/malformed cache files.

Thanks for reporting