terminal-bridge-setup 2.6.0 → 2.6.1

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.
@@ -30,9 +30,18 @@ function run(cmd, timeoutMs = 10000) {
30
30
  const reqId = randomBytes(4).toString("hex");
31
31
  let settled = false;
32
32
 
33
+ // 兜底超时定时器。关键:finish 时必须 clearTimeout——
34
+ // 否则即使结果 100ms 就到了,这个挂着的定时器会让 node 进程
35
+ // 一直活到定时器触发才退出,每次调用墙钟时间恒等于 timeoutMs+5000。
36
+ const fallbackTimer = setTimeout(
37
+ () => finish({ ok: false, error: "client timeout" }),
38
+ timeoutMs + 5000
39
+ );
40
+
33
41
  const finish = (result) => {
34
42
  if (settled) return;
35
43
  settled = true;
44
+ clearTimeout(fallbackTimer);
36
45
  try { ws.close(); } catch {}
37
46
  resolve(result);
38
47
  };
@@ -57,7 +66,6 @@ function run(cmd, timeoutMs = 10000) {
57
66
  });
58
67
 
59
68
  ws.on("error", (err) => finish({ ok: false, error: "ws error: " + err.message }));
60
- setTimeout(() => finish({ ok: false, error: "client timeout" }), timeoutMs + 5000);
61
69
  });
62
70
  }
63
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-bridge-setup",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "一次性安装器:释放终端桥接(JumpServer / Arthas)的本地代理 + Chrome 插件,并注册 native messaging host。让 Agent 能通过浏览器 xterm 终端执行命令并拿回输出。",
5
5
  "license": "MIT",
6
6
  "author": "encorearon",