From c83fd338631d88c568ee27e60ced58890f8e16af Mon Sep 17 00:00:00 2001 From: Nicu-Cosmin Ursache Date: Fri, 15 Jan 2021 15:16:44 +0200 Subject: [PATCH] bug fix for missing terminate function on dsuWorker in iframeHandler middleware --- middlewares/iframeHandler/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/middlewares/iframeHandler/index.js b/middlewares/iframeHandler/index.js index da697f8..5bd00f7 100644 --- a/middlewares/iframeHandler/index.js +++ b/middlewares/iframeHandler/index.js @@ -87,9 +87,13 @@ function IframeHandler(server) { if (code !== 0) { console.log(`Worker stopped with exit code ${code}`); // remove the worker from list in order to be recreated when needed - dsuWorkers[seed] = null; + delete dsuWorkers[seed]; } }); + + dsuWorker.terminate = function(){ + worker.terminate(); + } }); }), }; @@ -105,9 +109,8 @@ function IframeHandler(server) { console.log(`Stopping a number of ${Object.keys(dsuWorkers).length} thread workers`); for(let seed in dsuWorkers){ let worker = dsuWorkers[seed]; - if(typeof worker !== "undefined"){ + if(worker && worker.terminate){ worker.terminate(); - delete dsuWorkers[seed]; } } }