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);