cdp-tunnel 3.2.4 → 3.2.5
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
|
@@ -209,15 +209,17 @@ class PortPoolManager {
|
|
|
209
209
|
try { msg = JSON.parse(data.toString()); } catch { return; }
|
|
210
210
|
|
|
211
211
|
if (msg.id !== undefined) {
|
|
212
|
+
// createTarget 串行化(避免并发 chrome.tabs.create 回调串)
|
|
213
|
+
if (msg.method === 'Target.createTarget') {
|
|
214
|
+
while (session.createTargetLock) { await session.createTargetLock; }
|
|
215
|
+
session.createTargetLock = new Promise(r => { session._releaseCreateTarget = r; });
|
|
216
|
+
}
|
|
217
|
+
|
|
212
218
|
// 合成输入命令:先 bringToFront + 等待,再发原命令
|
|
213
219
|
if (SYNTHETIC_INPUT.indexOf(msg.method) >= 0 && msg.sessionId) {
|
|
214
220
|
await this._ensureVisible(session, pluginWs, msg.sessionId);
|
|
215
221
|
}
|
|
216
222
|
|
|
217
|
-
if (msg.method === 'Network.enable' || msg.method === 'Page.startScreencast') {
|
|
218
|
-
// 已转发,继续
|
|
219
|
-
}
|
|
220
|
-
|
|
221
223
|
// 命令:分配新 id,记录映射(含 method 名供响应后处理),转发给 plugin
|
|
222
224
|
const newId = `pool${session.portIndex}_${msg.id}`;
|
|
223
225
|
session.pendingRequests.set(newId, {
|
|
@@ -271,12 +273,18 @@ class PortPoolManager {
|
|
|
271
273
|
const pending = session.pendingRequests.get(msg.id);
|
|
272
274
|
session.pendingRequests.delete(msg.id);
|
|
273
275
|
|
|
274
|
-
// 如果是 createTarget 响应,记录 targetId → portIndex 归属 + 初始 url
|
|
276
|
+
// 如果是 createTarget 响应,记录 targetId → portIndex 归属 + 初始 url + 释放锁
|
|
275
277
|
if (msg.result && msg.result.targetId) {
|
|
276
278
|
const tid = msg.result.targetId;
|
|
277
279
|
session.targetIds.add(tid);
|
|
278
280
|
session.targetUrls.set(tid, pending?.params?.url || 'about:blank');
|
|
279
281
|
this.targetToPort.set(tid, portIndex);
|
|
282
|
+
// 释放 createTarget 锁
|
|
283
|
+
if (session._releaseCreateTarget) {
|
|
284
|
+
session._releaseCreateTarget();
|
|
285
|
+
session._releaseCreateTarget = null;
|
|
286
|
+
session.createTargetLock = null;
|
|
287
|
+
}
|
|
280
288
|
}
|
|
281
289
|
|
|
282
290
|
// 如果是 Page.navigate 响应,更新 targetId 的 url
|