[bidi][js] Add 'fetchError' command
diff --git a/javascript/node/selenium-webdriver/bidi/network.js b/javascript/node/selenium-webdriver/bidi/network.js
index 9a4755d..db5e370 100644
--- a/javascript/node/selenium-webdriver/bidi/network.js
+++ b/javascript/node/selenium-webdriver/bidi/network.js
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-const { BeforeRequestSent, ResponseStarted } = require('./networkTypes')
+const { BeforeRequestSent, ResponseStarted, FetchError} = require('./networkTypes')
 const {AddInterceptParameters} = require("./addInterceptParameters");
 
 class Network {
@@ -44,6 +44,10 @@
     await this.subscribeAndHandleEvent('network.authRequired', callback)
   }
 
+  async fetchError(callback) {
+    await this.subscribeAndHandleEvent('network.fetchError', callback)
+  }
+
   async subscribeAndHandleEvent(eventType, callback) {
     if (this._browsingContextIds != null) {
       await this.bidi.subscribe(eventType, this._browsingContextIds)
@@ -77,9 +81,18 @@
             params.timestamp,
             params.response,
           )
+        } else if ('errorText' in params) {
+          response = new FetchError(
+            params.context,
+            params.navigation,
+            params.redirectCount,
+            params.request,
+            params.timestamp,
+            params.errorText,
+          )
         }
         callback(response)
-      }
+        }
     })
   }
 
diff --git a/javascript/node/selenium-webdriver/bidi/networkTypes.js b/javascript/node/selenium-webdriver/bidi/networkTypes.js
index d727e0d..fea5a9b 100644
--- a/javascript/node/selenium-webdriver/bidi/networkTypes.js
+++ b/javascript/node/selenium-webdriver/bidi/networkTypes.js
@@ -347,6 +347,17 @@
   }
 }
 
+class FetchError extends BaseParameters {
+  constructor(id, navigation, redirectCount, request, timestamp, errorText) {
+    super(id, navigation, redirectCount, request, timestamp)
+    this._errorText = errorText
+  }
+
+  get errorText() {
+    return this._errorText
+  }
+}
+
 class ResponseData {
   constructor(
     url,
@@ -442,4 +453,4 @@
   }
 }
 
-module.exports = { BeforeRequestSent, ResponseStarted }
+module.exports = { BeforeRequestSent, ResponseStarted, FetchError }
diff --git a/javascript/node/selenium-webdriver/test/bidi/network_test.js b/javascript/node/selenium-webdriver/test/bidi/network_test.js
index 2c339d7..aa4b12d 100644
--- a/javascript/node/selenium-webdriver/test/bidi/network_test.js
+++ b/javascript/node/selenium-webdriver/test/bidi/network_test.js
@@ -19,8 +19,8 @@
 
 const assert = require('assert')
 const firefox = require('../../firefox')
-const { Browser } = require('../../')
-const { Pages, suite } = require('../../lib/test')
+const {Browser} = require('../../')
+const {Pages, suite} = require('../../lib/test')
 const Network = require('../../bidi/network')
 const until = require('../../lib/until')
 
@@ -174,6 +174,27 @@
         assert.equal(authRequiredEvent.response.url.includes('basicAuth'), true)
       })
 
+      xit('can listen to fetch error event', async function () {
+        let fetchErrorEvent = null
+        const network = await Network(driver)
+        await network.fetchError(function (event) {
+          fetchErrorEvent = event
+        })
+
+        try {
+          await driver.get('https://not_a_valid_url.test/')
+        } catch (e) {
+          // ignore
+        }
+
+        const url = fetchErrorEvent.request.url
+        assert.equal(fetchErrorEvent.id, await driver.getWindowHandle())
+        assert.equal(fetchErrorEvent.request.method, 'GET')
+        assert.equal(url.includes('valid_url'), true)
+        assert.equal(fetchErrorEvent.request.headers.length > 1, true)
+        assert.equal(fetchErrorEvent.errorText, 'NS_ERROR_UNKNOWN_HOST')
+      })
+
       it('test response completed mime type', async function () {
         let onResponseCompleted = []
         const network = await Network(driver)
@@ -196,5 +217,5 @@
       })
     })
   },
-  { browsers: [Browser.FIREFOX] },
+  {browsers: [Browser.FIREFOX]},
 )