From d7409cac1c4e4958d1c86b62f659b61c83b4b253 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 31 Dec 2023 21:42:00 +0100 Subject: [PATCH] Don't crash, when broken SVR.JS config is loaded. --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 272d269..a1c669c 100644 --- a/index.js +++ b/index.js @@ -12,8 +12,13 @@ try { } catch (ex) { // Can't determine version } -var configJSONS = JSON.parse(fs.readFileSync(__dirname + "/../../../config.json")); // Read configuration JSON - +var configJSONS = {}; +try { + configJSONS = JSON.parse(fs.readFileSync(__dirname + "/../../../config.json")); // Read configuration JSON +} catch(ex) { + //YellowSquare will not care about configJSONS in SVR.JS 3.x and newer + //SVR.JS 2.x and older will fail to start with broken configuration file anyway... +} class RequestBodyStream extends stream.Readable { constructor(sourceStream) { super();