MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / _failPending

Method _failPending

javascript/selenium-webdriver/bidi/index.js:149–174  ·  view source on GitHub ↗

* Reject any in-flight sends and mark the connection failed. Idempotent so * that close() and the underlying 'close'/'error' events do not double-reject. * @param {Error} error * @private

(error)

Source from the content-addressed store, hash-verified

147 * @private
148 */
149 _failPending(error) {
150 if (this._closed) {
151 return
152 }
153 this._closed = true
154 this.connected = false
155 for (const { reject, timeoutId } of this._pending.values()) {
156 clearTimeout(timeoutId)
157 reject(error)
158 }
159 this._pending.clear()
160 // Reject any callers parked in waitForConnection() so close() (or an
161 // unexpected disconnect) cannot leave them hanging forever.
162 for (const { reject } of this._connectWaiters) {
163 reject(error)
164 }
165 this._connectWaiters.clear()
166 // Detach every addCallback() listener too. Once closed, removeCallback()
167 // can no longer reach the remote end (send() would just throw), so nothing
168 // else will ever detach these listeners. Drop them here instead of leaving
169 // them attached to an EventEmitter nothing will ever emit on again.
170 for (const { method, handler } of this._callbacks.values()) {
171 this.off(method, handler)
172 }
173 this._callbacks.clear()
174 }
175
176 /**
177 * Emits `err` as an 'error' event if anything is listening for one,

Callers 2

constructorMethod · 0.95
closeMethod · 0.95

Calls 3

rejectFunction · 0.85
valuesMethod · 0.80
clearMethod · 0.65

Tested by

no test coverage detected