From 50d14394a6b7f18b25ad260a4d097c5daa3b3111 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Mon, 2 Apr 2018 14:59:58 +0200 Subject: [PATCH] Fixed error occasionally crashing client when plugins use lots of IO --- client.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client.js b/client.js index c9fb1062..e09743cc 100644 --- a/client.js +++ b/client.js @@ -473,15 +473,17 @@ function instanceManagement() { // send file contents to plugin for processing function fileChangeHandler(eventType, filename) { - // get array of lines in file - let stuff = fs.readFileSync(instancedirectory + "/script-output/" + filename, "utf8").split("\n"); - // if you found anything, reset the file - if (stuff[0]) { - fs.writeFileSync(instancedirectory + "/script-output/" + filename, ""); - } - for(let i = 0; i < stuff.length; i++) { - if(stuff[i]) { - plugins[I].scriptOutput(stuff[i]); + if(filename != null){ + // get array of lines in file + let stuff = fs.readFileSync(instancedirectory + "/script-output/" + filename, "utf8").split("\n"); + // if you found anything, reset the file + if (stuff[0]) { + fs.writeFileSync(instancedirectory + "/script-output/" + filename, ""); + } + for(let i = 0; i < stuff.length; i++) { + if(stuff[i]) { + plugins[I].scriptOutput(stuff[i]); + } } } }