From 8742e34d9fef67f39b7dbf997408e782156294fb Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Sat, 16 Sep 2017 16:47:16 +0200 Subject: [PATCH] Tried to fix occasional crash when saving related to getMac --- client.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/client.js b/client.js index 560c0b68..72c15172 100644 --- a/client.js +++ b/client.js @@ -420,20 +420,24 @@ function instanceManagement() { playerCount: instanceInfo.playerCount || 0, instanceName: instance, } - require('getmac').getMac(function (err, mac) { - if (err) throw err - payload.mac = mac - console.log("Registered our precense with master "+config.masterIP+" at " + payload.time); - needle.post(config.masterIP + ":" + config.masterPort + '/api/getID', payload, function (err, response, body) { - if (err && err.code != "ECONNRESET"){ - console.error("We got problems, something went wrong when contacting master"); - console.error(err); - } else if (response && response.body) { - // In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care. - console.log(response.body); - } + try { + require('getmac').getMac(function (err, mac) { + if (err) throw err + payload.mac = mac + console.log("Registered our precense with master "+config.masterIP+" at " + payload.time); + needle.post(config.masterIP + ":" + config.masterPort + '/api/getID', payload, function (err, response, body) { + if (err && err.code != "ECONNRESET"){ + console.error("We got problems, something went wrong when contacting master"); + console.error(err); + } else if (response && response.body) { + // In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care. + console.log(response.body); + } + }); }); - }); + } catch (e){ + console.log("##### getMac crashed, but we don't really give a shit because we are probably closing down #####"); + } },1000)}); } });