From 1eaa5f4c588e19c2b7e4d70a4577b83a7bf71a52 Mon Sep 17 00:00:00 2001 From: Hitesh Raghuvanshi Date: Fri, 24 Aug 2018 15:13:52 +0530 Subject: [PATCH 1/2] Adding try catch for parent process kill and increasing time interval for killed process check. --- lib/Local.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Local.js b/lib/Local.js index 054fe50..6381fb7 100644 --- a/lib/Local.js +++ b/lib/Local.js @@ -259,13 +259,17 @@ function Local(){ var killChecker = setInterval(() => { if(childPids.length === 0) { clearInterval(killChecker); - process.kill(this.pid); - - // This gives time to local binary to send kill signal to railsApp. - setTimeout(() => { + try { + process.kill(this.pid); + // This gives time to local binary to send kill signal to railsApp. + setTimeout(() => { + this.isProcessRunning = false; + callback(); + }, 2000); + } catch(err) { this.isProcessRunning = false; callback(); - }, 2000); + } } for(var i in childPids) { try { @@ -274,7 +278,7 @@ function Local(){ childPids.splice(i, 1); } } - },100); + },500); }); }; } From c5154548c5ca1b811336ecae370e0e5d39cbf273 Mon Sep 17 00:00:00 2001 From: Hitesh Raghuvanshi Date: Fri, 24 Aug 2018 15:14:46 +0530 Subject: [PATCH 2/2] Adding test for checking whether local stop is working or not --- test/local.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/local.js b/test/local.js index b4e20d9..79af54a 100644 --- a/test/local.js +++ b/test/local.js @@ -210,6 +210,17 @@ describe('Local', function () { }); }); + it('should stop local', function (done) { + this.timeout(MAX_TIMEOUT); + bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY}, function(){ + expect(bsLocal.isRunning()).to.equal(true); + bsLocal.stop(function(){ + expect(bsLocal.isRunning()).to.equal(false); + done(); + }); + }); + }); + afterEach(function (done) { this.timeout(60000); bsLocal.stop(done);