From 0c2f1e35bdde6311c60320b1a707c23f7ec70e22 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Thu, 3 Feb 2022 09:00:28 -0800 Subject: [PATCH] feat: Log the contents of the driver cache on failure to run the driver --- index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/index.js b/index.js index 6847008..cb77bb9 100644 --- a/index.js +++ b/index.js @@ -151,6 +151,23 @@ const LocalWebDriverBase = function( originalStart.call(this, url); }; + const originalOnProcessExit = this._onProcessExit; + this._onProcessExit = (code, signal, errorOutput) => { + originalOnProcessExit.call(this, code, signal, errorOutput); + + if (code == -1 && errorOutput.includes('Can not find')) { + // Failed to find the driver. Is it in the cache? Debug to help the + // user find out what's wrong. + try { + const contents = fs.readdirSync(DRIVER_CACHE); + log.error( + `Failed to find driver for ${this.browserName}`); + log.error( + `${DRIVER_CACHE} contains:`, JSON.stringify(contents, null, ' ')); + } catch (error) {} + } + }; + this.restart = async () => { if (this.state == 'BEING_FORCE_KILLED') { return;