Skip to content

Commit 8bed306

Browse files
DenysKuchmaclaude
andcommitted
fix(CDPBrowser): bound poll request timeout, prevent orphaned server process on failed start
- _waitForServer: each /json/version poll is bounded by a 1s (or remaining deadline) axios timeout, so a port held by something that never responds can not hang the run forever - _connect: self-managed resolution is attempted exactly once; on failure the error is stored and rethrown on subsequent connects instead of spawning a second process Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9dace7c commit 8bed306

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎lib/helper/CDPBrowser.js‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class CDPBrowser extends Helper {
320320
throw new Error(`Failed to start ${name} at ${this.binaryPath}: ${this.serverError.message}`)
321321
}
322322
try {
323-
await axios.get(`http://127.0.0.1:${this.options.port}/json/version`)
323+
await axios.get(`http://127.0.0.1:${this.options.port}/json/version`, { timeout: Math.min(1000, deadline - Date.now()) })
324324
return
325325
} catch (e) {
326326
await new Promise(r => setTimeout(r, 20))
@@ -340,9 +340,17 @@ class CDPBrowser extends Helper {
340340
* @protected
341341
*/
342342
async _connect() {
343-
if (this.server && !this._selfManagedResolved) {
344-
await this._resolveSelfManaged()
345-
this._selfManagedResolved = true
343+
if (this.server) {
344+
if (this._selfManagedError) throw this._selfManagedError
345+
if (!this._selfManagedResolved) {
346+
this._selfManagedResolved = true
347+
try {
348+
await this._resolveSelfManaged()
349+
} catch (err) {
350+
this._selfManagedError = err
351+
throw err
352+
}
353+
}
346354
}
347355
const endpoint = await this._resolveEndpoint()
348356
this.cdp = new CDPConnection(endpoint, { headers: this.options.headers, timeout: this.options.getPageTimeout * 1000 })

0 commit comments

Comments
 (0)