dsh-ris-ide 1.8.0 → 1.8.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.
Files changed (52) hide show
  1. package/README.md +5 -3
  2. package/bin/risd.mjs +14 -17
  3. package/lib/client.js +400 -93
  4. package/lib/debug/vendor/README.md +14 -0
  5. package/lib/debug/vendor/jdwp/client.js +9 -4
  6. package/lib/debug/vendor/src/jdwp/client.ts +12 -5
  7. package/lib/index.js +794 -48
  8. package/lib/proxybridge-bundle.js +1 -1
  9. package/lib/proxybridge-health.js +206 -0
  10. package/lib/redirector.js +1181 -90
  11. package/lib/risd/lifecycle.js +9 -3
  12. package/lib/risd/server.js +762 -26
  13. package/lib/risd/ui.js +419 -98
  14. package/lib/risd-client.js +4 -1
  15. package/lib/startup.js +27 -7
  16. package/package.json +2 -2
  17. package/test/client-viewer.test.mjs +299 -120
  18. package/test/clipboard.test.mjs +259 -0
  19. package/test/debug-engine.test.mjs +3 -1
  20. package/test/dsh-origin.test.mjs +4 -11
  21. package/test/dsh-window-refresh.test.mjs +166 -1
  22. package/test/harness.test.mjs +1 -1
  23. package/test/helpers/cmd.mjs +29 -0
  24. package/test/helpers/tgz.mjs +71 -0
  25. package/test/host-search.test.mjs +18 -11
  26. package/test/host-tail.test.mjs +119 -24
  27. package/test/proxy-route.test.mjs +61 -0
  28. package/test/proxy-window.test.mjs +5 -0
  29. package/test/proxy.test.mjs +13 -1
  30. package/test/proxybridge-bundle.test.mjs +1 -59
  31. package/test/proxybridge-health.test.mjs +116 -0
  32. package/test/redirector-bundle.test.mjs +21 -67
  33. package/test/redirector.test.mjs +395 -5
  34. package/test/risd-api.test.mjs +114 -17
  35. package/test/risd-bridge-degrade.test.mjs +3 -29
  36. package/test/risd-engine.test.mjs +13 -50
  37. package/test/risd-entry.test.mjs +0 -37
  38. package/test/risd-follow-start.test.mjs +101 -0
  39. package/test/risd-git.test.mjs +7 -5
  40. package/test/risd-handoff.test.mjs +6 -50
  41. package/test/risd-helpers.mjs +150 -3
  42. package/test/risd-host-p2.test.mjs +2 -30
  43. package/test/risd-lifecycle.test.mjs +25 -0
  44. package/test/risd-programs.test.mjs +4 -34
  45. package/test/risd-restart.test.mjs +104 -0
  46. package/test/risd-review-p2.test.mjs +0 -13
  47. package/test/risd-shutdown.test.mjs +5 -38
  48. package/test/risd-teardown.test.mjs +8 -27
  49. package/test/risd-ui.test.mjs +322 -4
  50. package/test/risd-write.test.mjs +2 -1
  51. package/test/startup-reconcile.test.mjs +44 -8
  52. package/test/proxy-restart.test.mjs +0 -37
@@ -18,6 +18,20 @@
18
18
  | 内存 | +5MB RSS(实测) | ~40–60MB |
19
19
  | 集成 | 面板/agent/路由共用同一会话 | 工具在 `mcp__jvm-debug__*`,面板需另建通道 |
20
20
 
21
+ ## 本地补丁(重 vendor 时必须保留)
22
+
23
+ **`sendCommand` 的看门狗定时器要清掉**(2026-11-11,`jdwp/client.js` 与 `src/jdwp/client.ts` 同步):
24
+
25
+ ```js
26
+ const timer = setTimeout(() => { /* 超时 reject */ }, this.timeout)
27
+ timer.unref?.()
28
+ this.pendingRequests.set(id, { resolve, reject, timer })
29
+ // processBuffer 收到对应 reply 时:
30
+ clearTimeout(pending.timer)
31
+ ```
32
+
33
+ 上游原实现每条命令都留一个 **10 s** 定时器、且不 `unref`、回复到达也不 `clearTimeout`:最后一条命令之后事件循环被吊满 10 s(`test/debug-engine.test.mjs` 因此从 1.9 s 变成 12.5 s),真实调试会话收尾也会白等。清理点就是收 reply 的那一支(`const pending = this.pendingRequests.get(id)` 之后、`pending.resolve(...)` 之前)——`clearTimeout(undefined)` 本身是安全的,所以不额外判空;别把清理只写在 `delete` 之后却漏掉 early-return 的分支。
34
+
21
35
  ## 重新构建(上游有更新或改了 TS 源码时)
22
36
 
23
37
  ```bash
@@ -178,6 +178,7 @@ export class JDWPClient extends EventEmitter {
178
178
  const pending = this.pendingRequests.get(id);
179
179
  if (pending) {
180
180
  this.pendingRequests.delete(id);
181
+ clearTimeout(pending.timer);
181
182
  pending.resolve({ id, flags: FLAGS_REPLY, errorCode, data });
182
183
  }
183
184
  }
@@ -308,15 +309,19 @@ export class JDWPClient extends EventEmitter {
308
309
  }
309
310
  const id = this.nextId++;
310
311
  const packet = buildCommandPacket(id, commandSet, command, data);
311
- this.pendingRequests.set(id, { resolve, reject });
312
- this.socket.write(packet);
313
- // Timeout after 10 seconds
314
- setTimeout(() => {
312
+ // The timeout is kept with the request so the reply can clear it: a timer
313
+ // left behind per command keeps the event loop alive for 10 s after the
314
+ // last command (a test run then hangs for seconds), and a long debug
315
+ // session would accumulate one timer per command.
316
+ const timer = setTimeout(() => {
315
317
  if (this.pendingRequests.has(id)) {
316
318
  this.pendingRequests.delete(id);
317
319
  reject(new Error(`Command timeout: cmdSet=${commandSet}, cmd=${command}`));
318
320
  }
319
321
  }, 10000);
322
+ timer.unref?.();
323
+ this.pendingRequests.set(id, { resolve, reject, timer });
324
+ this.socket.write(packet);
320
325
  });
321
326
  }
322
327
  checkError(reply) {
@@ -75,6 +75,8 @@ export interface VariableInfo {
75
75
  interface PendingRequest {
76
76
  resolve: (reply: ReplyPacket) => void;
77
77
  reject: (err: Error) => void;
78
+ /** The per-command watchdog, cleared by the reply (see `sendCommand`). */
79
+ timer?: ReturnType<typeof setTimeout>;
78
80
  }
79
81
 
80
82
  /**
@@ -278,6 +280,7 @@ export class JDWPClient extends EventEmitter {
278
280
  const pending = this.pendingRequests.get(id);
279
281
  if (pending) {
280
282
  this.pendingRequests.delete(id);
283
+ clearTimeout(pending.timer);
281
284
  pending.resolve({ id, flags: FLAGS_REPLY, errorCode, data });
282
285
  }
283
286
  } else {
@@ -417,16 +420,20 @@ export class JDWPClient extends EventEmitter {
417
420
  const id = this.nextId++;
418
421
  const packet = buildCommandPacket(id, commandSet, command, data);
419
422
 
420
- this.pendingRequests.set(id, { resolve, reject });
421
- this.socket.write(packet);
422
-
423
- // Timeout after 10 seconds
424
- setTimeout(() => {
423
+ // The timeout is kept with the request so the reply can clear it: a timer
424
+ // left behind per command keeps the event loop alive for 10 s after the last
425
+ // command (a test run then hangs for seconds), and a long debug session would
426
+ // accumulate one timer per command.
427
+ const timer = setTimeout(() => {
425
428
  if (this.pendingRequests.has(id)) {
426
429
  this.pendingRequests.delete(id);
427
430
  reject(new Error(`Command timeout: cmdSet=${commandSet}, cmd=${command}`));
428
431
  }
429
432
  }, 10000);
433
+ timer.unref?.();
434
+
435
+ this.pendingRequests.set(id, { resolve, reject, timer });
436
+ this.socket.write(packet);
430
437
  });
431
438
  }
432
439