arn-browser 0.1.33 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -611,14 +611,27 @@ async function spawnAndConnect({ binaryPath, profilePath, isPersistent, proxy, t
|
|
|
611
611
|
process.once("SIGHUP", signalHandler);
|
|
612
612
|
|
|
613
613
|
if (_launchLogs) console.log(`░░░░░ ${browserLabel} started on port ${debugPort}`);
|
|
614
|
-
await sleep(2000);
|
|
615
614
|
|
|
616
|
-
// Connect via CDP
|
|
615
|
+
// Connect via CDP — retry up to 10 times (2s apart) to handle slow startups
|
|
616
|
+
const MAX_CONNECT_RETRIES = 10;
|
|
617
|
+
const CONNECT_RETRY_DELAY = 2000;
|
|
618
|
+
|
|
617
619
|
try {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
620
|
+
for (let attempt = 1; attempt <= MAX_CONNECT_RETRIES; attempt++) {
|
|
621
|
+
try {
|
|
622
|
+
await sleep(CONNECT_RETRY_DELAY);
|
|
623
|
+
browser = await puppeteer.connect({
|
|
624
|
+
browserURL: `http://127.0.0.1:${debugPort}`,
|
|
625
|
+
defaultViewport: null,
|
|
626
|
+
});
|
|
627
|
+
break; // Connected successfully
|
|
628
|
+
} catch (connectErr) {
|
|
629
|
+
if (attempt === MAX_CONNECT_RETRIES) {
|
|
630
|
+
throw connectErr; // All retries exhausted — propagate
|
|
631
|
+
}
|
|
632
|
+
console.log(`░░░░░ CDP connect attempt ${attempt}/${MAX_CONNECT_RETRIES} failed, retrying in ${CONNECT_RETRY_DELAY / 1000}s...`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
622
635
|
|
|
623
636
|
if (_launchLogs) console.log(`░░░░░ Connected to ${browserLabel} via CDP (port ${debugPort})`);
|
|
624
637
|
|