Don't crash on bad plugins.json; fixes #2323

pull/2324/head
Beau Gunderson 2014-11-18 13:52:42 -08:00
parent 135aa3e8fe
commit 645ec830b0
1 changed files with 6 additions and 1 deletions

View File

@ -66,7 +66,12 @@ exports.getAvailablePlugins = function(maxCacheAge, cb) {
if(exports.availablePlugins && maxCacheAge && Math.round(+new Date/1000)-cacheTimestamp <= maxCacheAge) {
return cb && cb(null, exports.availablePlugins)
}
plugins = JSON.parse(plugins);
try {
plugins = JSON.parse(plugins);
} catch (err) {
console.error('error parsing plugins.json:', err);
plugins = [];
}
exports.availablePlugins = plugins;
cacheTimestamp = Math.round(+new Date/1000);
cb && cb(null, plugins)