cdp-tunnel 2.9.3 → 2.9.4

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.
@@ -41,8 +41,11 @@ var ConnectionManager = (function() {
41
41
  var entry = _connections.get(connectionId);
42
42
  if (!entry) return;
43
43
 
44
+ entry.wsManager._removed = true;
44
45
  entry.state.clearReconnectTimer();
45
46
  if (entry.state.ws) {
47
+ entry.state.ws.onclose = null;
48
+ entry.state.ws.onerror = null;
46
49
  try { entry.state.ws.close(); } catch(e) {}
47
50
  }
48
51
  entry.state.clearAllState();
@@ -97,10 +100,12 @@ var ConnectionManager = (function() {
97
100
 
98
101
  function disconnectAll() {
99
102
  _connections.forEach(function(entry) {
103
+ entry.state.clearReconnectTimer();
100
104
  if (entry.state.ws) {
105
+ entry.state.ws.onclose = null;
106
+ entry.state.ws.onerror = null;
101
107
  try { entry.state.ws.close(); } catch(e) {}
102
108
  }
103
- entry.state.clearReconnectTimer();
104
109
  });
105
110
  }
106
111
 
@@ -32,10 +32,15 @@ var WebSocketConnection = (function() {
32
32
  this._maxQueueSize = 100;
33
33
  this._bufferThreshold = 512 * 1024;
34
34
  this._groupCreationPending = new Set();
35
+ this._removed = false;
35
36
  }
36
37
 
37
38
  WebSocketConnection.prototype.connect = function() {
38
39
  var self = this;
40
+ if (self._removed) {
41
+ Logger.info('[WS:' + self.connectionId + '] Skipping connect, connection removed');
42
+ return;
43
+ }
39
44
  var ws = self.state.getWs();
40
45
  if (ws && (ws.readyState === WebSocket.CONNECTING || ws.readyState === WebSocket.OPEN)) {
41
46
  return;
@@ -43,6 +48,10 @@ var WebSocketConnection = (function() {
43
48
 
44
49
  var wsUrl = self.config.url;
45
50
  Config.getPluginId(function(pluginId) {
51
+ if (self._removed) {
52
+ Logger.info('[WS:' + self.connectionId + '] Aborting connect (async), connection removed');
53
+ return;
54
+ }
46
55
  if (pluginId) {
47
56
  var sep = wsUrl.indexOf('?') >= 0 ? '&' : '?';
48
57
  wsUrl += sep + 'pluginId=' + encodeURIComponent(pluginId);
@@ -150,9 +159,14 @@ var WebSocketConnection = (function() {
150
159
  };
151
160
 
152
161
  WebSocketConnection.prototype._scheduleReconnect = function() {
162
+ if (this._removed) {
163
+ Logger.info('[WS:' + this.connectionId + '] Skipping reconnect, connection removed');
164
+ return;
165
+ }
153
166
  this.state.clearReconnectTimer();
154
167
  var self = this;
155
168
  var timer = setTimeout(function() {
169
+ if (self._removed) return;
156
170
  Logger.info('[WS:' + self.connectionId + '] Attempting to reconnect...');
157
171
  self.connect();
158
172
  }, Config.RECONNECT_DELAY);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "2.9.3",
4
+ "version": "2.9.4",
5
5
  "description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
6
6
  "permissions": [
7
7
  "debugger",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "2.9.3",
3
+ "version": "2.9.4",
4
4
  "description": "Bridge Chrome's debugger API to WebSocket — control your existing browser with Playwright/Puppeteer via CDP",
5
5
  "main": "server/proxy-server.js",
6
6
  "bin": "./cli/index.js",
@@ -67,6 +67,7 @@
67
67
  "ws": "^8.16.0"
68
68
  },
69
69
  "devDependencies": {
70
+ "chrome-remote-interface": "^0.34.0",
70
71
  "husky": "^9.1.7",
71
72
  "lz-string": "^1.5.0",
72
73
  "pako": "^2.1.0",
@@ -350,7 +350,8 @@ async function handleHttpRequest(req, res) {
350
350
  'User-Agent': userAgent,
351
351
  'V8-Version': ver?.jsVersion || '',
352
352
  'WebKit-Version': '537.36',
353
- webSocketDebuggerUrl: `ws://${getHost(req)}/devtools/browser/${browserId}`
353
+ webSocketDebuggerUrl: `ws://${getHost(req)}/devtools/browser/${browserId}`,
354
+ totalPlugins: pluginConnections.size
354
355
  };
355
356
  res.writeHead(200, { 'Content-Type': 'application/json' });
356
357
  res.end(JSON.stringify(payload));