cdp-tunnel 2.7.0 → 2.7.2
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.
|
@@ -27,12 +27,13 @@ importScripts('features/automation-badge.js');
|
|
|
27
27
|
keepAliveInterval = setInterval(function() {
|
|
28
28
|
var ws = State.getWs();
|
|
29
29
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
30
|
-
Logger.info('[KeepAlive] Sending heartbeat');
|
|
31
30
|
WebSocketManager.send({ type: 'keepalive', timestamp: Date.now() });
|
|
32
31
|
}
|
|
33
32
|
}, 20000);
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
|
|
34
|
+
chrome.alarms.clear('sw-keepalive', function() {
|
|
35
|
+
chrome.alarms.create('sw-keepalive', { periodInMinutes: 0.4 });
|
|
36
|
+
});
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
function stopKeepAlive() {
|
|
@@ -362,5 +363,16 @@ importScripts('features/automation-badge.js');
|
|
|
362
363
|
return true;
|
|
363
364
|
});
|
|
364
365
|
|
|
366
|
+
chrome.alarms.onAlarm.addListener(function(alarm) {
|
|
367
|
+
if (alarm.name === 'sw-keepalive') {
|
|
368
|
+
var ws = State.getWs();
|
|
369
|
+
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
370
|
+
WebSocketManager.send({ type: 'keepalive', timestamp: Date.now() });
|
|
371
|
+
} else {
|
|
372
|
+
WebSocketManager.connect();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
|
|
365
377
|
init();
|
|
366
378
|
})();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "CDP Bridge",
|
|
4
|
-
"version": "2.7.
|
|
4
|
+
"version": "2.7.2",
|
|
5
5
|
"description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
|
|
6
6
|
"permissions": [
|
|
7
7
|
"debugger",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"scripting",
|
|
11
11
|
"storage",
|
|
12
12
|
"downloads",
|
|
13
|
-
"tabGroups"
|
|
13
|
+
"tabGroups",
|
|
14
|
+
"alarms"
|
|
14
15
|
],
|
|
15
16
|
"host_permissions": [
|
|
16
17
|
"<all_urls>"
|
package/package.json
CHANGED
package/server/modules/config.js
CHANGED
|
@@ -9,7 +9,8 @@ const CONFIG = {
|
|
|
9
9
|
CLIENT_IDLE_TIMEOUT: 300000,
|
|
10
10
|
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
|
|
11
11
|
AUTO_RESTART: process.env.AUTO_RESTART === 'true',
|
|
12
|
-
CHROME_RESTART_COOLDOWN: 30000
|
|
12
|
+
CHROME_RESTART_COOLDOWN: 30000,
|
|
13
|
+
PLUGIN_MAX_MISSED_PINGS: 3
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const LOG_LEVELS = {
|
package/server/proxy-server.js
CHANGED
|
@@ -923,11 +923,9 @@ function handlePluginConnection(ws, clientInfo, request) {
|
|
|
923
923
|
}
|
|
924
924
|
if (mapping.isGetTargets && parsed.result && parsed.result.targetInfos) {
|
|
925
925
|
const clientId = mapping.clientId;
|
|
926
|
-
const pluginWsForGetTargets = ws;
|
|
927
926
|
parsed.result.targetInfos = parsed.result.targetInfos.filter(t => {
|
|
928
927
|
if (t.type !== 'page') return true;
|
|
929
928
|
const ownerClient = ns.targetIdToClientId.get(t.targetId);
|
|
930
|
-
if (!ownerClient) return true;
|
|
931
929
|
return ownerClient === clientId;
|
|
932
930
|
});
|
|
933
931
|
console.log(`[GET TARGETS FILTERED] client=${clientId} returned ${parsed.result.targetInfos.filter(t => t.type === 'page').length} page targets`);
|
|
@@ -1634,12 +1632,20 @@ const heartbeatInterval = setInterval(() => {
|
|
|
1634
1632
|
|
|
1635
1633
|
pluginConnections.forEach((ws) => {
|
|
1636
1634
|
if (!ws.isAlive) {
|
|
1637
|
-
|
|
1638
|
-
|
|
1635
|
+
ws.missedPings = (ws.missedPings || 0) + 1;
|
|
1636
|
+
if (ws.missedPings >= CONFIG.PLUGIN_MAX_MISSED_PINGS) {
|
|
1637
|
+
if (shouldLog('warn')) {
|
|
1638
|
+
console.log(`[${now}] Plugin ${ws.id} missed ${ws.missedPings} pings, terminating...`);
|
|
1639
|
+
}
|
|
1640
|
+
logConnectionEvent('HEARTBEAT_TIMEOUT', { type: 'plugin', id: ws.id, missedPings: ws.missedPings });
|
|
1641
|
+
cleanupPlugin(ws, ws.id, 'heartbeat_timeout');
|
|
1642
|
+
return ws.terminate();
|
|
1639
1643
|
}
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1644
|
+
if (shouldLog('info')) {
|
|
1645
|
+
console.log(`[${now}] Plugin ${ws.id} missed ping ${ws.missedPings}/${CONFIG.PLUGIN_MAX_MISSED_PINGS}`);
|
|
1646
|
+
}
|
|
1647
|
+
} else {
|
|
1648
|
+
ws.missedPings = 0;
|
|
1643
1649
|
}
|
|
1644
1650
|
ws.isAlive = false;
|
|
1645
1651
|
ws.ping();
|