From d120e7e42661ace6827378c1330ca7fa59fc6246 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 11 Jul 2017 08:11:16 -0700 Subject: [PATCH] properly cleanup exit process listener as browser closes --- lib/Browser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Browser.js b/lib/Browser.js index 931c2bb2..0626b3d8 100644 --- a/lib/Browser.js +++ b/lib/Browser.js @@ -112,9 +112,11 @@ class Browser { let stderr = ''; this._chromeProcess.stderr.on('data', data => stderr += data.toString('utf8')); // Cleanup as processes exit. - process.on('exit', () => this._chromeProcess.kill()); + const onProcessExit = () => this._chromeProcess.kill(); + process.on('exit', onProcessExit); this._chromeProcess.on('exit', () => { this._terminated = true; + process.removeListener('exit', onProcessExit); removeRecursive(this._userDataDir); }); this._chromeProcess.stderr.pipe(this.stderr);