iobroker.javascript 10.3.0 → 10.4.0

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 (161) hide show
  1. package/README.md +20 -9
  2. package/admin/assets/AiChatPanel-BjRIKaXG.js +27 -0
  3. package/admin/assets/{AiChatService-QKcpW4jQ.js → AiChatService-DP1EmVk2.js} +3 -3
  4. package/admin/assets/AiDiffView-DeynDw7L.js +1 -0
  5. package/admin/assets/{AiInlineProvider-DTSPKoXG.js → AiInlineProvider-jkEIJJJ-.js} +1 -1
  6. package/admin/assets/{BlocklyEditor-BZyoN1JE.js → BlocklyEditor-DhwThchX.js} +7 -7
  7. package/admin/assets/Compile-e8N5zI-J.js +165 -0
  8. package/admin/assets/Debugger-BDQUKM1K.js +15 -0
  9. package/admin/assets/Diff--plofAtP.js +1 -0
  10. package/admin/assets/{Documentation-uz4Ut9pT.js → Documentation-D3E0U4AK.js} +4 -4
  11. package/admin/assets/ExpandMore-Dio4GeHC.js +1 -0
  12. package/admin/assets/{FbEditor-aOZ-RpPV.js → FbEditor-BjLPNzpK.js} +6 -6
  13. package/admin/assets/History-Ewi5YEEn.js +1 -0
  14. package/admin/assets/Import-6Mm2vrM2.js +1 -0
  15. package/admin/assets/MonacoDiff-BYvG7IqB.js +1 -0
  16. package/admin/assets/{NotificationsActive-BdzH44gp.js → NotificationsActive-CuNfWVJM.js} +1 -1
  17. package/admin/assets/RulesEditor--YX6ETsU.js +1 -0
  18. package/admin/assets/{ScriptEditor-CviB6Hif.js → ScriptEditor-BadPC8Mf.js} +2 -2
  19. package/admin/assets/ScriptEditorVanillaMonaco-BnAmy59d.js +3 -0
  20. package/admin/assets/Send-Pz1eveU5.js +1 -0
  21. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-Ceh8EDcF.js +1 -0
  22. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__234968779812303__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BRdHvuuG.js +1217 -0
  23. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__234968779812303__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DLWT3PGo.js +9 -0
  24. package/admin/assets/aiPromptBuilder-Co6AqZwx.js +1 -0
  25. package/admin/assets/{blockly-fcfyKYzp.js → blockly-B0t_IRJQ.js} +1 -1
  26. package/admin/assets/{blocklyTheme-CGhU3cEO.js → blocklyTheme-iZoge1S9.js} +1 -1
  27. package/admin/assets/{blocks_action-BQ4O7NRE.js → blocks_action-Ctn5A1AU.js} +1 -1
  28. package/admin/assets/{blocks_convert-0VBjfhqQ.js → blocks_convert-BI0lf0sf.js} +1 -1
  29. package/admin/assets/{blocks_logic-DAo99xDr.js → blocks_logic-o49klUX_.js} +1 -1
  30. package/admin/assets/{blocks_number-C--e19NU.js → blocks_number-DZtyWFyR.js} +1 -1
  31. package/admin/assets/{blocks_object-D0TPhdzg.js → blocks_object-BuzGCxVr.js} +1 -1
  32. package/admin/assets/blocks_procedures-jn9sIYmR.js +3 -0
  33. package/admin/assets/{blocks_sendto-CRIrtOUc.js → blocks_sendto-Coui8w1H.js} +2 -2
  34. package/admin/assets/{blocks_switch-b_GYfF0n.js → blocks_switch-CeRZizTM.js} +1 -1
  35. package/admin/assets/{blocks_system-BdkUdSsc.js → blocks_system-CaBPIC40.js} +1 -1
  36. package/admin/assets/{blocks_text-DSFhEVOf.js → blocks_text-DeDtPYWf.js} +1 -1
  37. package/admin/assets/{blocks_time-CqALAiJp.js → blocks_time-CTXQH3Lm.js} +1 -1
  38. package/admin/assets/{blocks_timeout-yrOD2pZp.js → blocks_timeout-D8IOKOb-.js} +1 -1
  39. package/admin/assets/{blocks_trigger-DeAYXpSS.js → blocks_trigger-zuuXJbhb.js} +2 -2
  40. package/admin/assets/{cronHoverProvider-DoO2_tpG.js → cronHoverProvider-Curcjz4m.js} +1 -1
  41. package/admin/assets/dist-CzitsFi7.js +1 -0
  42. package/admin/assets/field_cron-RgLY53_S.js +1 -0
  43. package/admin/assets/field_oid-rBhotXJe.js +1 -0
  44. package/admin/assets/field_script-CU7g3-oB.js +1 -0
  45. package/admin/assets/helpers-BZgjFQNf.js +1 -0
  46. package/admin/assets/{helpers-BTGaTdnT.js → helpers-BwllSRzJ.js} +1 -1
  47. package/admin/assets/hostInit-CrHjJGJJ.js +1 -0
  48. package/admin/assets/index-Bmmscq2G.js +157 -0
  49. package/admin/assets/{inlineChatWidget-BwQVCPkx.js → inlineChatWidget-ChchJD9a.js} +1 -1
  50. package/admin/assets/{inlineDiffController-BsDDsDHn.js → inlineDiffController-ly6qX4jk.js} +1 -1
  51. package/admin/assets/{loadBlocks-RpqM7PwO.js → loadBlocks-BcFtthDb.js} +23 -23
  52. package/admin/assets/{mf-entry-bootstrap-0-0deef484.js → mf-entry-bootstrap-0-6db6c4fc.js} +3 -3
  53. package/admin/assets/pendingShares-mBGPbRwZ.js +2 -0
  54. package/admin/assets/{reactour.esm-DX9ZgYlx.js → reactour.esm-Dk3aGxKn.js} +5 -5
  55. package/admin/assets/{stateHoverProvider-BEadnSXp.js → stateHoverProvider-wAsP-THx.js} +1 -1
  56. package/admin/assets/utils-DUKzLJUz.js +4 -0
  57. package/admin/assets/vite-preload-helper-DjNwdemH.js +1 -0
  58. package/admin/custom/assets/Components-fDcxCyN4.js +1 -0
  59. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-BraOrMSu.js +1 -0
  60. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-DbKT6Hsb.js +1 -0
  61. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-CVvbIPAy.js +1 -0
  62. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-DVb0ZZ1Q.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BhZYie9-.js} +89 -89
  63. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-CV50dgj4.js +1 -0
  64. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare__date_mf_2_fns__loadShare__.js-Djg9OMcQ.js +1 -0
  65. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare__leaflet__loadShare__.js-D9EyCd42.js +1 -0
  66. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare__shared-Hb6V6BnJ.js +2 -0
  67. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-BrY-nF2a.js +122 -0
  68. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__prebuild__leaflet__prebuild__-CHjWtrkp.js +1 -0
  69. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__prebuild__react_mf_2_dom_mf_1_client__prebuild__-DOkC-g0X.js +9 -0
  70. package/admin/custom/assets/dist-CzitsFi7.js +1 -0
  71. package/admin/custom/assets/helpers-BZgjFQNf.js +1 -0
  72. package/admin/custom/assets/hostInit-akwaQLq8.js +1 -0
  73. package/admin/custom/assets/index-BkItz-nL.js +1 -0
  74. package/admin/custom/assets/{lib-BmDlTzq2.js → lib-CADOx2YN.js} +1 -1
  75. package/admin/custom/assets/{mf-entry-bootstrap-0-ad1cd7d0.js → mf-entry-bootstrap-0-3c4565e0.js} +3 -3
  76. package/admin/custom/assets/pendingShares-TCMDgBLn.js +2 -0
  77. package/admin/custom/assets/utils-DUKzLJUz.js +4 -0
  78. package/admin/custom/assets/vite-preload-helper-DjNwdemH.js +1 -0
  79. package/admin/custom/customComponents.js +2 -2
  80. package/admin/custom/i18n/de.json +19 -1
  81. package/admin/custom/i18n/en.json +19 -1
  82. package/admin/custom/i18n/es.json +19 -1
  83. package/admin/custom/i18n/fr.json +19 -1
  84. package/admin/custom/i18n/it.json +19 -1
  85. package/admin/custom/i18n/nl.json +19 -1
  86. package/admin/custom/i18n/pl.json +19 -1
  87. package/admin/custom/i18n/pt.json +19 -1
  88. package/admin/custom/i18n/ru.json +19 -1
  89. package/admin/custom/i18n/uk.json +19 -1
  90. package/admin/custom/i18n/zh-cn.json +19 -1
  91. package/admin/i18n/de.json +13 -1
  92. package/admin/i18n/en.json +13 -1
  93. package/admin/i18n/es.json +13 -1
  94. package/admin/i18n/fr.json +13 -1
  95. package/admin/i18n/it.json +13 -1
  96. package/admin/i18n/nl.json +13 -1
  97. package/admin/i18n/pl.json +13 -1
  98. package/admin/i18n/pt.json +13 -1
  99. package/admin/i18n/ru.json +13 -1
  100. package/admin/i18n/uk.json +13 -1
  101. package/admin/i18n/zh-cn.json +13 -1
  102. package/admin/jsonConfig.json +274 -86
  103. package/admin/mf-manifest.json +1 -1
  104. package/admin/mf-stats.json +1 -1
  105. package/admin/remoteEntry.js +2 -2
  106. package/admin/tab.html +2 -2
  107. package/build/lib/aiProviderResolver.js +145 -25
  108. package/build/lib/aiProviderResolver.js.map +1 -1
  109. package/build/lib/anthropicAdapter.js +37 -0
  110. package/build/lib/anthropicAdapter.js.map +1 -1
  111. package/build/lib/inspect.js +66 -10
  112. package/build/lib/inspect.js.map +1 -1
  113. package/build/lib/mirror.js +24 -23
  114. package/build/lib/mirror.js.map +1 -1
  115. package/build/lib/scriptHistory.js +245 -0
  116. package/build/lib/scriptHistory.js.map +1 -0
  117. package/build/main.js +575 -31
  118. package/build/main.js.map +1 -1
  119. package/build/types.d.ts +11 -0
  120. package/io-package.json +17 -15
  121. package/package.json +7 -7
  122. package/admin/assets/AiChatPanel-CpY4Bun-.js +0 -27
  123. package/admin/assets/AiDiffView-DscPfZ38.js +0 -1
  124. package/admin/assets/Compile-Oss28m_f.js +0 -165
  125. package/admin/assets/Debugger-teJTIU-2.js +0 -15
  126. package/admin/assets/ExpandMore-V5Ix1QB1.js +0 -1
  127. package/admin/assets/Import-BIC5Ee9z.js +0 -1
  128. package/admin/assets/RulesEditor-CcDVthPa.js +0 -1
  129. package/admin/assets/ScriptEditorVanillaMonaco-ByuXwybM.js +0 -3
  130. package/admin/assets/Send-Mdo32jMb.js +0 -1
  131. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-BnL93BgK.js +0 -1
  132. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__180366418666083__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-NI-3Uv4e.js +0 -1217
  133. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__180366418666083__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DVaMIZyC.js +0 -9
  134. package/admin/assets/aiPromptBuilder-yTB6N2VT.js +0 -1
  135. package/admin/assets/blocks_procedures-DgTxgXdB.js +0 -3
  136. package/admin/assets/dist-D4uJqRBO.js +0 -4
  137. package/admin/assets/field_cron-D3Ts_s9M.js +0 -1
  138. package/admin/assets/field_oid-BRNXredg.js +0 -1
  139. package/admin/assets/field_script-3X6ousg7.js +0 -1
  140. package/admin/assets/hostInit-2h2Cbsaw.js +0 -1
  141. package/admin/assets/index-CbQlIKB_.js +0 -156
  142. package/admin/assets/pendingShares-BaAadIDv.js +0 -1
  143. package/admin/assets/vite-preload-helper-CaC3yEL3.js +0 -1
  144. package/admin/custom/assets/Components-FkGDIlId.js +0 -1
  145. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-Cs88NUCd.js +0 -1
  146. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-P-8ffWXw.js +0 -1
  147. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-ZVuRAEo5.js +0 -1
  148. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-Dna3WF04.js +0 -1
  149. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-DcjdCGAx.js +0 -1
  150. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__date_mf_2_fns__loadShare__.js-CnhNjamd.js +0 -1
  151. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__leaflet__loadShare__.js-Dz7BFJqH.js +0 -1
  152. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-B0olko2J.js +0 -1
  153. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-CzN4reh_.js +0 -122
  154. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__leaflet__prebuild__-xPcBaiTQ.js +0 -1
  155. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__react_mf_2_dom_mf_1_client__prebuild__-DuFBE5fh.js +0 -9
  156. package/admin/custom/assets/dist-D4uJqRBO.js +0 -4
  157. package/admin/custom/assets/hostInit-6oh4UY2k.js +0 -1
  158. package/admin/custom/assets/index-BrlyEy6J.js +0 -1
  159. package/admin/custom/assets/pendingShares-kV2kwejX.js +0 -1
  160. package/admin/custom/assets/vite-preload-helper-CaC3yEL3.js +0 -1
  161. /package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-CXpyx8Vy.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-CXpyx8Vy.js} +0 -0
@@ -59,6 +59,26 @@ let inspector;
59
59
  let scriptToDebug = '';
60
60
  /** Main file of the debugged adapter */
61
61
  let instanceToDebug = '';
62
+ /** The inspector is on its way out, so every further request to end it is ignored */
63
+ let ending = false;
64
+ /**
65
+ * End this process, but stop the debugged process first and give it the time to shut down.
66
+ * Its output goes through the pipes of this process, so they must stay open till it is gone (see `stopChild`).
67
+ */
68
+ async function endInspector(exitCode) {
69
+ if (ending) {
70
+ return;
71
+ }
72
+ ending = true;
73
+ try {
74
+ await inspector?.stopChild();
75
+ }
76
+ catch (e) {
77
+ debuglog(`Cannot stop the debugged process: ${e}`);
78
+ }
79
+ // Give the last messages to the host the chance to leave
80
+ setTimeout(() => process.exit(exitCode), 200);
81
+ }
62
82
  function sendToHost(data) {
63
83
  if (data.cmd === 'error') {
64
84
  console.error(`[DEBUGGER] ${data.error}`);
@@ -217,6 +237,7 @@ class NodeInspector {
217
237
  this.Runtime.runIfWaitingForDebugger(),
218
238
  ]);
219
239
  }
240
+ /** Kill the debugged process without waiting for it. Only for the exit handler, where nothing can be awaited */
220
241
  killChild() {
221
242
  this.client.reset();
222
243
  if (this.child) {
@@ -224,6 +245,33 @@ class NodeInspector {
224
245
  this.child = null;
225
246
  }
226
247
  }
248
+ /**
249
+ * Stop the debugged process and wait till it is really gone.
250
+ *
251
+ * The debugged process is started with `--debug`, so it writes its whole log to the stdout of this process, and it
252
+ * logs while it is shutting down. If this process would end first, these pipes would be closed under it and every
253
+ * further log line would fail with `EPIPE` - which the adapter reports as an uncaught exception and dies (#2382).
254
+ */
255
+ async stopChild(timeoutMs = 3_000) {
256
+ this.client.reset();
257
+ const child = this.child;
258
+ this.child = null;
259
+ if (!child || child.exitCode !== null || child.signalCode !== null) {
260
+ return;
261
+ }
262
+ await new Promise(resolve => {
263
+ const timeout = setTimeout(() => {
264
+ // It does not want to end - take the hard way
265
+ child.kill('SIGKILL');
266
+ resolve();
267
+ }, timeoutMs);
268
+ child.once('exit', () => {
269
+ clearTimeout(timeout);
270
+ resolve();
271
+ });
272
+ child.kill();
273
+ });
274
+ }
227
275
  finish(reason) {
228
276
  if (this.finished) {
229
277
  return;
@@ -231,8 +279,7 @@ class NodeInspector {
231
279
  this.finished = true;
232
280
  debuglog(reason);
233
281
  sendToHost({ cmd: 'finished', text: reason });
234
- this.killChild();
235
- setTimeout(() => process.exit(0), 200);
282
+ void endInspector(0);
236
283
  }
237
284
  childPrint(text, isError) {
238
285
  if (isError) {
@@ -449,8 +496,7 @@ function startDebugging(data) {
449
496
  reportError(e instanceof StartupError
450
497
  ? e.message
451
498
  : `Internal error in inspector: ${e instanceof Error ? e.stack : errorToString(e)}`);
452
- inspector?.killChild();
453
- setTimeout(() => process.exit(1), 200);
499
+ void endInspector(1);
454
500
  });
455
501
  }
456
502
  async function processCommand(data) {
@@ -460,7 +506,8 @@ async function processCommand(data) {
460
506
  return;
461
507
  }
462
508
  if (data.cmd === 'end') {
463
- process.exit(0);
509
+ await endInspector(0);
510
+ return;
464
511
  }
465
512
  if (!inspector) {
466
513
  reportError(`Cannot process "${data.cmd}": the debugger is not started`);
@@ -629,15 +676,24 @@ process.on('message', (message) => {
629
676
  }
630
677
  processCommand(command).catch(e => reportError(`Cannot process "${command?.cmd}"`, e));
631
678
  });
679
+ // A closed pipe of the own output (the host can be gone already) must not end the inspector with an EPIPE
680
+ process.stdout.on('error', () => { });
681
+ process.stderr.on('error', () => { });
632
682
  // Handle all possible exits and never leave the debugged process behind
633
683
  process.on('exit', () => inspector?.killChild());
634
- process.on('disconnect', () => process.exit(0));
635
- process.once('SIGTERM', () => process.exit(0));
636
- process.once('SIGHUP', () => process.exit(0));
684
+ process.on('disconnect', () => void endInspector(0));
685
+ process.once('SIGTERM', () => void endInspector(0));
686
+ process.once('SIGHUP', () => void endInspector(0));
637
687
  process.on('uncaughtException', (e) => {
688
+ // The connection to the debugged process is reset as soon as it ends (node-inspect's client does not listen for
689
+ // that), and while the inspector is on its way out, there is nothing worth reporting anymore
690
+ if (ending || e?.code === 'ECONNRESET' || e?.code === 'EPIPE') {
691
+ debuglog(`Ignored error in the inspector: ${e?.stack || e?.message}`);
692
+ void endInspector(0);
693
+ return;
694
+ }
638
695
  reportError(`Internal error in inspector: ${e.stack || e.message}`);
639
- inspector?.killChild();
640
- process.exit(1);
696
+ void endInspector(1);
641
697
  });
642
698
  sendToHost({ cmd: 'ready' });
643
699
  //# sourceMappingURL=inspect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/lib/inspect.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;AAEH;;;;;;;;GAQG;AACH,2DAAgF;AAChF,qCAAmD;AAEnD,yCAA4C;AAC5C,uCAAyC;AACzC,yCAAqD;AAErD,sCAAsC;AACtC,8FAAqE;AAErE,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAAC,SAAS,CAAC,CAAC;AAEzC,0GAA0G;AAC1G,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAE7D;;;GAGG;AACH,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AAU,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC","sourcesContent":["/*\n * Copyright Node.js contributors. All rights reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/*\n * The inspector process. It is forked by the adapter (see `debugStart` in main.ts) and starts the process to debug -\n * the javascript adapter itself with `--debugScript <scriptId>` or another adapter - with an enabled inspector.\n * It connects to it via the DevTools protocol and translates the commands of the GUI into protocol calls and back.\n *\n * The communication with the host happens via IPC with JSON strings:\n * - host -> inspector: `DebugCommand`\n * - inspector -> host: `CommandToHost`\n */\nimport { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport type { Debugger, Runtime } from 'node:inspector';\nimport { join, normalize } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { debuglog as utilDebugLog } from 'node:util';\n\n// @ts-expect-error no types available\nimport InspectClient from 'node-inspect/lib/internal/inspect_client';\n\nconst debuglog = utilDebugLog('inspect');\n\n/** Stay paused on the first line of the debugged process (used for the debugging of adapter instances) */\nconst breakOnStart = process.argv.includes('--breakOnStart');\n\n/**\n * By debugging of a script, stepping and \"stop on exception\" should not stop in the node internals,\n * in 3rd party modules and in the adapter itself (e.g., in sandbox.js)\n */\nconst SCRIPT_BLACKBOX_PATTERNS = ['^node:', '/node_modules/', '[iI]o[bB]roker\\\\.javascript/build/'];\n\ninterface InspectClientType {\n connect(port: number, host: string): Promise<void>;\n callMethod(method: string, params?: Record<string, unknown>): Promise<any>;\n reset(): void;\n on(event: 'debugEvent', listener: (method: string, params: DebugEventParams | undefined) => void): void;\n}\n\ntype ProtocolDomain = Record<string, (params?: Record<string, unknown>) => Promise<any>>;\n\n/** Parameters of the protocol events, which are processed here */\ninterface DebugEventParams {\n /** Debugger.scriptParsed */\n scriptId?: Runtime.ScriptId;\n url?: string;\n /** Debugger.paused */\n reason?: string;\n callFrames?: Debugger.CallFrame[];\n /** Runtime.consoleAPICalled */\n type?: string;\n args?: Runtime.RemoteObject[];\n /** Runtime.executionContextDestroyed */\n executionContextId?: number;\n /** Runtime.executionContextCreated */\n context?: { id: number; name: string };\n}\n\ninterface CommandToHost {\n cmd:\n | 'ready'\n | 'readyToDebug'\n | 'paused'\n | 'resumed'\n | 'script'\n | 'log'\n | 'error'\n | 'finished'\n | 'sb'\n | 'cb'\n | 'scope'\n | 'setValue'\n | 'expressions'\n | 'getPossibleBreakpoints';\n [attr: string]: unknown;\n}\n\ninterface DebugCommand {\n cmd:\n | 'start'\n | 'end'\n | 'source'\n | 'sb'\n | 'cb'\n | 'pause'\n | 'cont'\n | 'next'\n | 'step'\n | 'out'\n | 'scope'\n | 'setValue'\n | 'expressions'\n | 'stopOnException'\n | 'getPossibleBreakpoints';\n /** start: ID of the script to debug, like `script.js.myScript` */\n scriptName?: string;\n /** start: instance number of the javascript adapter */\n instance?: number;\n /** start: adapter instance to debug, like `hm-rpc.0`, if no script name is given */\n adapterInstance?: string;\n /** source */\n scriptId?: Runtime.ScriptId;\n /** sb: locations, cb: breakpoint IDs */\n breakpoints?: (Debugger.Location | Debugger.BreakpointId)[];\n /** scope: scopes of the current call frame with their index in the scope chain */\n scopes?: (Debugger.Scope & { index?: number })[];\n /** setValue */\n variableName?: string;\n scopeNumber?: number;\n newValue?: { value?: unknown };\n /** setValue, expressions */\n callFrameId?: Debugger.CallFrameId;\n /** expressions */\n expressions?: { name: string }[];\n /** stopOnException */\n state?: boolean;\n /** getPossibleBreakpoints */\n start?: Debugger.Location;\n end?: Debugger.Location;\n}\n\nclass StartupError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'StartupError';\n }\n}\n\nlet inspector: NodeInspector | undefined;\n/** ID of the debugged script, like `script.js.myScript` */\nlet scriptToDebug = '';\n/** Main file of the debugged adapter */\nlet instanceToDebug = '';\n\nfunction sendToHost(data: CommandToHost): void {\n if (data.cmd === 'error') {\n console.error(`[DEBUGGER] ${data.error as string}`);\n }\n try {\n process.send?.(JSON.stringify(data));\n } catch (e) {\n // The host is not reachable anymore\n console.error(`[DEBUGGER] Cannot send to host: ${e as Error}`);\n }\n}\n\nfunction errorToString(e: unknown): string {\n if (e instanceof Error) {\n return e.message;\n }\n return typeof e === 'string' ? e : JSON.stringify(e);\n}\n\nfunction reportError(text: string, e?: unknown): void {\n sendToHost({ cmd: 'error', error: e === undefined ? text : `${text}: ${errorToString(e)}` });\n}\n\nfunction remoteObjectToString(obj: Runtime.RemoteObject | undefined): string {\n if (!obj) {\n return '';\n }\n if (obj.value !== undefined) {\n return typeof obj.value === 'string' ? obj.value : JSON.stringify(obj.value);\n }\n return obj.unserializableValue || obj.description || obj.type;\n}\n\nfunction consoleTypeToSeverity(type: string | undefined): ioBroker.LogLevel {\n switch (type) {\n case 'warning':\n return 'warn';\n case 'error':\n case 'assert':\n return 'error';\n case 'debug':\n return 'debug';\n default:\n return 'info';\n }\n}\n\n/** Values like NaN, Infinity, -0 or BigInt cannot be transferred as JSON value */\nfunction toCallArgument(value: unknown): Runtime.CallArgument {\n if (typeof value === 'number' && (!Number.isFinite(value) || Object.is(value, -0))) {\n return { unserializableValue: Object.is(value, -0) ? '-0' : String(value) };\n }\n if (typeof value === 'bigint') {\n return { unserializableValue: `${value}n` };\n }\n return value === undefined ? {} : { value };\n}\n\nfunction isUrlOfFile(url: string, file: string): boolean {\n let path = url;\n if (url.startsWith('file://')) {\n try {\n path = fileURLToPath(url);\n } catch {\n return false;\n }\n }\n path = normalize(path);\n file = normalize(file);\n return process.platform === 'win32' ? path.toLowerCase() === file.toLowerCase() : path === file;\n}\n\nfunction createDomain(domain: string, client: InspectClientType): ProtocolDomain {\n return new Proxy<ProtocolDomain>(\n {},\n {\n get: (_target, method: string | symbol) =>\n // the object must not look like a promise\n typeof method === 'string' && method !== 'then'\n ? (params?: Record<string, unknown>): Promise<any> =>\n client.callMethod(`${domain}.${method}`, params)\n : undefined,\n },\n );\n}\n\nfunction runScript(\n script: string,\n scriptArgs: string[],\n childPrint: (text: string, isError?: boolean) => void,\n): Promise<[ChildProcessWithoutNullStreams, number, string]> {\n return new Promise((resolve, reject) => {\n // Always break on start: the process must not run before the debugger is connected, else it could\n // execute the `debugger;` statement of the script before. Port 0 means any free port.\n const child = spawn(process.execPath, ['--inspect-brk=127.0.0.1:0', normalize(script), ...scriptArgs]);\n child.stdout.setEncoding('utf8');\n child.stderr.setEncoding('utf8');\n child.stdout.on('data', (text: string) => childPrint(text));\n child.stderr.on('data', (text: string) => childPrint(text, true));\n\n let output = '';\n const timeout = setTimeout(() => {\n child.stderr.removeListener('data', waitForListenHint);\n child.kill();\n reject(new StartupError('Timeout by starting of the process to debug'));\n }, 10_000);\n\n function waitForListenHint(text: string): void {\n output += text;\n const res = /Debugger listening on ws:\\/\\/\\[?(.+?)]?:(\\d+)\\//.exec(output);\n if (res) {\n clearTimeout(timeout);\n child.stderr.removeListener('data', waitForListenHint);\n resolve([child, parseInt(res[2], 10), res[1]]);\n }\n }\n\n child.stderr.on('data', waitForListenHint);\n child.on('error', error => {\n clearTimeout(timeout);\n reject(new StartupError(`Cannot start the process to debug: ${error.message}`));\n });\n });\n}\n\nclass NodeInspector {\n readonly Debugger: ProtocolDomain;\n readonly Runtime: ProtocolDomain;\n\n private readonly client: InspectClientType = new InspectClient();\n private readonly file: string;\n private readonly args: string[];\n private child: ChildProcessWithoutNullStreams | null = null;\n /** The protocol does not deliver the URLs in the call frames anymore, so remember them */\n private readonly scriptUrls: Record<Runtime.ScriptId, string> = {};\n private mainScriptId: Runtime.ScriptId | undefined;\n private mainFile = '';\n private mainScriptSource: Promise<string> | null = null;\n /** Sometimes the first pause comes before the main script is parsed */\n private delayedContext: DebugEventParams | null = null;\n private pausedOnFirstLine = false;\n /** Execution context of the debugged script */\n private scriptContextId: number | undefined;\n private finished = false;\n\n constructor(file: string, args: string[]) {\n this.file = file;\n this.args = args;\n this.Debugger = createDomain('Debugger', this.client);\n this.Runtime = createDomain('Runtime', this.client);\n this.client.on('debugEvent', (fullName, params) => this.handleDebugEvent(fullName, params || {}));\n }\n\n async start(): Promise<void> {\n const [child, port, host] = await runScript(this.file, this.args, (text, isError) =>\n this.childPrint(text, isError),\n );\n this.child = child;\n child.on('exit', code => this.finish(`Process exited with code ${code}`));\n\n for (let attempt = 1; ; attempt++) {\n try {\n await this.client.connect(port, host);\n break;\n } catch (e) {\n debuglog(`Connection attempt #${attempt} failed: ${e as Error}`);\n if (attempt >= 10) {\n throw new StartupError(`Cannot connect to the debugger on ${host}:${port}`);\n }\n await new Promise(resolve => setTimeout(resolve, 500));\n }\n }\n\n await Promise.all([\n this.Runtime.enable(),\n this.Debugger.enable(),\n this.Debugger.setPauseOnExceptions({ state: 'none' }),\n this.Debugger.setAsyncCallStackDepth({ maxDepth: 1 }),\n this.Debugger.setBlackboxPatterns({ patterns: scriptToDebug ? SCRIPT_BLACKBOX_PATTERNS : [] }),\n this.Runtime.runIfWaitingForDebugger(),\n ]);\n }\n\n killChild(): void {\n this.client.reset();\n if (this.child) {\n this.child.kill();\n this.child = null;\n }\n }\n\n private finish(reason: string): void {\n if (this.finished) {\n return;\n }\n this.finished = true;\n debuglog(reason);\n sendToHost({ cmd: 'finished', text: reason });\n this.killChild();\n setTimeout(() => process.exit(0), 200);\n }\n\n private childPrint(text: string, isError?: boolean): void {\n if (isError) {\n const lines = text\n .split(/\\r\\n|\\r|\\n/g)\n .filter(line => !!line)\n .map(line => `< ${line}`);\n lines.length && process.stdout.write(`${lines.join('\\n')}\\n`);\n }\n // The debugged process ended, but it waits till the debugger disconnects\n if (text.includes('Waiting for the debugger to disconnect')) {\n this.finish('Process finished');\n }\n }\n\n private handleDebugEvent(fullName: string, params: DebugEventParams): void {\n switch (fullName) {\n case 'Debugger.scriptParsed':\n this.onScriptParsed(params);\n break;\n\n case 'Debugger.paused':\n this.onPaused(params);\n break;\n\n case 'Debugger.resumed':\n sendToHost({ cmd: 'resumed', context: params });\n break;\n\n case 'Runtime.consoleAPICalled':\n this.onConsoleApiCalled(params);\n break;\n\n case 'Runtime.executionContextCreated':\n // main.ts gives the context of a script the name of the script\n if (scriptToDebug && params.context?.name === scriptToDebug) {\n this.scriptContextId = params.context.id;\n }\n break;\n\n case 'Runtime.executionContextDestroyed':\n if (params.executionContextId === 1) {\n // the main context of the debugged process is gone\n this.finish('Process finished');\n } else if (this.scriptContextId !== undefined && params.executionContextId === this.scriptContextId) {\n // the script was stopped, but the process is still running\n sendToHost({ cmd: 'finished', context: params });\n }\n break;\n\n default:\n debuglog(`${fullName}: ${JSON.stringify(params)}`);\n break;\n }\n }\n\n private onScriptParsed(params: DebugEventParams): void {\n const { scriptId, url } = params;\n if (!scriptId || !url) {\n return;\n }\n this.scriptUrls[scriptId] = url;\n\n const isMain = scriptToDebug ? url === scriptToDebug : !!instanceToDebug && isUrlOfFile(url, instanceToDebug);\n if (!isMain) {\n return;\n }\n debuglog(`Script to debug parsed: ${scriptId}`);\n this.mainScriptId = scriptId;\n this.mainFile = url.replace('file:///', '');\n this.mainScriptSource = this.Debugger.getScriptSource({ scriptId }).then(\n (result: Debugger.GetScriptSourceReturnType) => result.scriptSource,\n );\n\n if (this.delayedContext) {\n const context = this.delayedContext;\n this.delayedContext = null;\n void this.sendReadyToDebug(context);\n }\n }\n\n private onPaused(params: DebugEventParams): void {\n if (!this.pausedOnFirstLine) {\n if (params.reason === 'Break on start' && !breakOnStart) {\n // the process was started with --inspect-brk only to have time to set up the debugger\n this.Debugger.resume().catch(e => reportError('Cannot resume', e));\n return;\n }\n if (params.reason === 'exception') {\n // ignore all exceptions till the start of the script\n this.Debugger.resume().catch(e => reportError('Cannot resume', e));\n return;\n }\n }\n\n this.enrichCallFrames(params);\n\n if (\n this.pausedOnFirstLine &&\n scriptToDebug &&\n params.reason === 'step' &&\n !params.callFrames?.[0]?.url?.startsWith('script.js.')\n ) {\n // Stepping left the script, e.g., at the end of a callback. The blackbox patterns do not cover\n // all internals of node.js, so continue the execution instead of stopping there\n this.Debugger.resume().catch(e => reportError('Cannot resume', e));\n return;\n }\n\n if (this.pausedOnFirstLine) {\n sendToHost({ cmd: 'paused', context: params });\n } else {\n this.pausedOnFirstLine = true;\n if (this.mainScriptSource) {\n void this.sendReadyToDebug(params);\n } else {\n // store the context to send it, when the main script is parsed\n this.delayedContext = params;\n }\n }\n }\n\n private async sendReadyToDebug(context: DebugEventParams): Promise<void> {\n try {\n const script = await this.mainScriptSource;\n this.enrichCallFrames(context);\n sendToHost({\n cmd: 'readyToDebug',\n scriptId: this.mainScriptId,\n script,\n context,\n url: this.mainFile,\n });\n } catch (e) {\n reportError('Cannot read the source of the script to debug', e);\n }\n }\n\n private enrichCallFrames(context: DebugEventParams): void {\n context.callFrames?.forEach(frame => {\n if (!frame.url) {\n frame.url = this.scriptUrls[frame.location.scriptId] || '';\n }\n });\n }\n\n private onConsoleApiCalled(params: DebugEventParams): void {\n const args = params.args || [];\n if (instanceToDebug) {\n sendToHost({\n cmd: 'log',\n severity: consoleTypeToSeverity(params.type),\n text: args.map(arg => remoteObjectToString(arg)).join(' '),\n ts: Date.now(),\n });\n return;\n }\n\n // The sandbox logs in debug mode as `console.log(`${severity}$$${scriptName}$$${message}`, Date.now())`\n const text = remoteObjectToString(args[0]);\n const marker = `$$${scriptToDebug}$$`;\n const pos = text.indexOf(marker);\n if (pos !== -1) {\n sendToHost({\n cmd: 'log',\n severity: text.substring(0, pos),\n text: text.substring(pos + marker.length),\n ts: typeof args[1]?.value === 'number' ? args[1].value : Date.now(),\n });\n } else if (params.type === 'warning' || params.type === 'error') {\n sendToHost({\n cmd: 'log',\n severity: consoleTypeToSeverity(params.type),\n text: args.map(arg => remoteObjectToString(arg)).join(' '),\n ts: Date.now(),\n });\n }\n }\n}\n\nfunction resolveAdapterMainFile(adapter: string): string | undefined {\n try {\n return require.resolve(`iobroker.${adapter}`);\n } catch {\n // try to locate it in the same node_modules directory as this adapter\n const dir = normalize(join(__dirname, '..', '..', '..', `iobroker.${adapter}`));\n if (existsSync(join(dir, 'package.json'))) {\n try {\n const pack = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));\n const main = join(dir, pack.main || `${adapter}.js`);\n if (existsSync(main)) {\n return main;\n }\n } catch {\n // ignore\n }\n }\n }\n return undefined;\n}\n\nfunction startDebugging(data: DebugCommand): void {\n if (inspector) {\n reportError('The debugger is already started');\n return;\n }\n\n if (data.scriptName) {\n scriptToDebug = data.scriptName;\n inspector = new NodeInspector(join(__dirname, '..', 'main.js'), [\n (data.instance || 0).toString(),\n '--debug',\n '--debugScript',\n scriptToDebug,\n ]);\n } else {\n const [adapter, instance] = (data.adapterInstance || '').split('.');\n const file = resolveAdapterMainFile(adapter);\n if (!file) {\n reportError(`Cannot locate iobroker.${adapter}`);\n setTimeout(() => {\n sendToHost({ cmd: 'finished', context: `Cannot locate iobroker.${adapter}` });\n setTimeout(() => process.exit(0), 500);\n }, 200);\n return;\n }\n instanceToDebug = file;\n inspector = new NodeInspector(file, [instance || '0', '--debug']);\n }\n\n inspector.start().catch((e: unknown) => {\n reportError(\n e instanceof StartupError\n ? e.message\n : `Internal error in inspector: ${e instanceof Error ? e.stack : errorToString(e)}`,\n );\n inspector?.killChild();\n setTimeout(() => process.exit(1), 200);\n });\n}\n\nasync function processCommand(data: DebugCommand): Promise<void> {\n debuglog(`processCommand: ${JSON.stringify(data)}`);\n\n if (data.cmd === 'start') {\n startDebugging(data);\n return;\n }\n if (data.cmd === 'end') {\n process.exit(0);\n }\n if (!inspector) {\n reportError(`Cannot process \"${data.cmd}\": the debugger is not started`);\n return;\n }\n const { Debugger, Runtime } = inspector;\n\n switch (data.cmd) {\n case 'source':\n try {\n const { scriptSource } = (await Debugger.getScriptSource({\n scriptId: data.scriptId,\n })) as Debugger.GetScriptSourceReturnType;\n sendToHost({ cmd: 'script', scriptId: data.scriptId, text: scriptSource });\n } catch (e) {\n reportError(`Cannot read the source of script ${data.scriptId}`, e);\n }\n break;\n\n case 'cont':\n case 'next':\n case 'step':\n case 'out':\n case 'pause': {\n const method = { cont: 'resume', next: 'stepOver', step: 'stepInto', out: 'stepOut', pause: 'pause' }[\n data.cmd\n ];\n try {\n await Debugger[method]();\n } catch (e) {\n reportError(`Cannot execute \"${data.cmd}\"`, e);\n }\n break;\n }\n\n case 'sb': {\n const breakpoints = await Promise.all(\n ((data.breakpoints || []) as Debugger.Location[]).map(async bp => {\n try {\n const result = (await Debugger.setBreakpoint({\n location: {\n scriptId: bp.scriptId,\n lineNumber: bp.lineNumber,\n columnNumber: bp.columnNumber,\n },\n })) as Debugger.SetBreakpointReturnType;\n return { id: result.breakpointId, location: result.actualLocation };\n } catch (e) {\n reportError(`Cannot set breakpoint on line ${bp.lineNumber + 1}`, e);\n return null;\n }\n }),\n );\n sendToHost({ cmd: 'sb', breakpoints: breakpoints.filter(bp => bp) });\n break;\n }\n\n case 'cb': {\n const breakpointIds = await Promise.all(\n ((data.breakpoints || []) as Debugger.BreakpointId[]).map(async breakpointId => {\n try {\n await Debugger.removeBreakpoint({ breakpointId });\n } catch (e) {\n // The breakpoint does not exist (anymore), so it is removed anyway\n debuglog(`Cannot clear breakpoint ${breakpointId}: ${e as Error}`);\n }\n return breakpointId;\n }),\n );\n sendToHost({ cmd: 'cb', breakpoints: breakpointIds });\n break;\n }\n\n case 'scope': {\n const scopes = await Promise.all(\n (data.scopes || [])\n .filter(scope => scope?.object?.objectId)\n .map(async scope => {\n try {\n const properties = (await Runtime.getProperties({\n objectId: scope.object.objectId,\n generatePreview: true,\n })) as Runtime.GetPropertiesReturnType;\n return { type: scope.type, name: scope.name, index: scope.index, properties };\n } catch (e) {\n // e.g., the execution was resumed in the meantime\n debuglog(`Cannot read scope: ${e as Error}`);\n return null;\n }\n }),\n );\n sendToHost({ cmd: 'scope', scopes: scopes.filter(scope => scope) });\n break;\n }\n\n case 'setValue':\n try {\n await Debugger.setVariableValue({\n variableName: data.variableName,\n scopeNumber: data.scopeNumber,\n newValue: toCallArgument(data.newValue?.value),\n callFrameId: data.callFrameId,\n });\n sendToHost({\n cmd: 'setValue',\n variableName: data.variableName,\n scopeNumber: data.scopeNumber,\n newValue: data.newValue,\n callFrameId: data.callFrameId,\n });\n } catch (e) {\n reportError(`Cannot set value of \"${data.variableName}\"`, e);\n }\n break;\n\n case 'expressions': {\n const expressions = await Promise.all(\n (data.expressions || []).map(async item => {\n try {\n const { result } = (await Debugger.evaluateOnCallFrame({\n callFrameId: data.callFrameId,\n expression: item.name,\n objectGroup: 'node-inspect',\n generatePreview: true,\n })) as Debugger.EvaluateOnCallFrameReturnType;\n return { name: item.name, result };\n } catch (e) {\n return {\n name: item.name,\n result: {\n type: 'object',\n subtype: 'error',\n className: 'Error',\n description: errorToString(e),\n },\n };\n }\n }),\n );\n sendToHost({ cmd: 'expressions', expressions });\n break;\n }\n\n case 'stopOnException':\n try {\n await Debugger.setPauseOnExceptions({ state: data.state ? 'all' : 'none' });\n } catch (e) {\n reportError('Cannot change \"stop on exception\"', e);\n }\n break;\n\n case 'getPossibleBreakpoints':\n try {\n const { locations } = (await Debugger.getPossibleBreakpoints({\n start: data.start,\n end: data.end,\n })) as Debugger.GetPossibleBreakpointsReturnType;\n sendToHost({ cmd: 'getPossibleBreakpoints', breakpoints: locations });\n } catch (e) {\n reportError('Cannot get possible breakpoints', e);\n }\n break;\n\n default:\n console.error(`[DEBUGGER] Unknown command: ${JSON.stringify(data)}`);\n break;\n }\n}\n\nprocess.on('message', (message: unknown): void => {\n let command: DebugCommand;\n try {\n command = typeof message === 'string' ? (JSON.parse(message) as DebugCommand) : (message as DebugCommand);\n } catch {\n console.error(`[DEBUGGER] Cannot parse: ${JSON.stringify(message)}`);\n return;\n }\n processCommand(command).catch(e => reportError(`Cannot process \"${command?.cmd}\"`, e));\n});\n\n// Handle all possible exits and never leave the debugged process behind\nprocess.on('exit', () => inspector?.killChild());\nprocess.on('disconnect', () => process.exit(0));\nprocess.once('SIGTERM', () => process.exit(0));\nprocess.once('SIGHUP', () => process.exit(0));\nprocess.on('uncaughtException', (e: Error) => {\n reportError(`Internal error in inspector: ${e.stack || e.message}`);\n inspector?.killChild();\n process.exit(1);\n});\n\nsendToHost({ cmd: 'ready' });\n"]}
1
+ {"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/lib/inspect.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;AAEH;;;;;;;;GAQG;AACH,2DAAgF;AAChF,qCAAmD;AAEnD,yCAA4C;AAC5C,uCAAyC;AACzC,yCAAqD;AAErD,sCAAsC;AACtC,8FAAqE;AAErE,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAAC,SAAS,CAAC,CAAC;AAEzC,0GAA0G;AAC1G,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,gBAAgB,EAAE,oCAAoC,CAAC,CAAC;AA2FpG,MAAM,YAAa,SAAQ,KAAK;IAC5B,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,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AAC,CAAC;IACpE,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC","sourcesContent":["/*\n * Copyright Node.js contributors. All rights reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/*\n * The inspector process. It is forked by the adapter (see `debugStart` in main.ts) and starts the process to debug -\n * the javascript adapter itself with `--debugScript <scriptId>` or another adapter - with an enabled inspector.\n * It connects to it via the DevTools protocol and translates the commands of the GUI into protocol calls and back.\n *\n * The communication with the host happens via IPC with JSON strings:\n * - host -> inspector: `DebugCommand`\n * - inspector -> host: `CommandToHost`\n */\nimport { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport type { Debugger, Runtime } from 'node:inspector';\nimport { join, normalize } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { debuglog as utilDebugLog } from 'node:util';\n\n// @ts-expect-error no types available\nimport InspectClient from 'node-inspect/lib/internal/inspect_client';\n\nconst debuglog = utilDebugLog('inspect');\n\n/** Stay paused on the first line of the debugged process (used for the debugging of adapter instances) */\nconst breakOnStart = process.argv.includes('--breakOnStart');\n\n/**\n * By debugging of a script, stepping and \"stop on exception\" should not stop in the node internals,\n * in 3rd party modules and in the adapter itself (e.g., in sandbox.js)\n */\nconst SCRIPT_BLACKBOX_PATTERNS = ['^node:', '/node_modules/', '[iI]o[bB]roker\\\\.javascript/build/'];\n\ninterface InspectClientType {\n connect(port: number, host: string): Promise<void>;\n callMethod(method: string, params?: Record<string, unknown>): Promise<any>;\n reset(): void;\n on(event: 'debugEvent', listener: (method: string, params: DebugEventParams | undefined) => void): void;\n}\n\ntype ProtocolDomain = Record<string, (params?: Record<string, unknown>) => Promise<any>>;\n\n/** Parameters of the protocol events, which are processed here */\ninterface DebugEventParams {\n /** Debugger.scriptParsed */\n scriptId?: Runtime.ScriptId;\n url?: string;\n /** Debugger.paused */\n reason?: string;\n callFrames?: Debugger.CallFrame[];\n /** Runtime.consoleAPICalled */\n type?: string;\n args?: Runtime.RemoteObject[];\n /** Runtime.executionContextDestroyed */\n executionContextId?: number;\n /** Runtime.executionContextCreated */\n context?: { id: number; name: string };\n}\n\ninterface CommandToHost {\n cmd:\n | 'ready'\n | 'readyToDebug'\n | 'paused'\n | 'resumed'\n | 'script'\n | 'log'\n | 'error'\n | 'finished'\n | 'sb'\n | 'cb'\n | 'scope'\n | 'setValue'\n | 'expressions'\n | 'getPossibleBreakpoints';\n [attr: string]: unknown;\n}\n\ninterface DebugCommand {\n cmd:\n | 'start'\n | 'end'\n | 'source'\n | 'sb'\n | 'cb'\n | 'pause'\n | 'cont'\n | 'next'\n | 'step'\n | 'out'\n | 'scope'\n | 'setValue'\n | 'expressions'\n | 'stopOnException'\n | 'getPossibleBreakpoints';\n /** start: ID of the script to debug, like `script.js.myScript` */\n scriptName?: string;\n /** start: instance number of the javascript adapter */\n instance?: number;\n /** start: adapter instance to debug, like `hm-rpc.0`, if no script name is given */\n adapterInstance?: string;\n /** source */\n scriptId?: Runtime.ScriptId;\n /** sb: locations, cb: breakpoint IDs */\n breakpoints?: (Debugger.Location | Debugger.BreakpointId)[];\n /** scope: scopes of the current call frame with their index in the scope chain */\n scopes?: (Debugger.Scope & { index?: number })[];\n /** setValue */\n variableName?: string;\n scopeNumber?: number;\n newValue?: { value?: unknown };\n /** setValue, expressions */\n callFrameId?: Debugger.CallFrameId;\n /** expressions */\n expressions?: { name: string }[];\n /** stopOnException */\n state?: boolean;\n /** getPossibleBreakpoints */\n start?: Debugger.Location;\n end?: Debugger.Location;\n}\n\nclass StartupError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'StartupError';\n }\n}\n\nlet inspector: NodeInspector | undefined;\n/** ID of the debugged script, like `script.js.myScript` */\nlet scriptToDebug = '';\n/** Main file of the debugged adapter */\nlet instanceToDebug = '';\n/** The inspector is on its way out, so every further request to end it is ignored */\nlet ending = false;\n\n/**\n * End this process, but stop the debugged process first and give it the time to shut down.\n * Its output goes through the pipes of this process, so they must stay open till it is gone (see `stopChild`).\n */\nasync function endInspector(exitCode: number): Promise<void> {\n if (ending) {\n return;\n }\n ending = true;\n try {\n await inspector?.stopChild();\n } catch (e) {\n debuglog(`Cannot stop the debugged process: ${e as Error}`);\n }\n // Give the last messages to the host the chance to leave\n setTimeout(() => process.exit(exitCode), 200);\n}\n\nfunction sendToHost(data: CommandToHost): void {\n if (data.cmd === 'error') {\n console.error(`[DEBUGGER] ${data.error as string}`);\n }\n try {\n process.send?.(JSON.stringify(data));\n } catch (e) {\n // The host is not reachable anymore\n console.error(`[DEBUGGER] Cannot send to host: ${e as Error}`);\n }\n}\n\nfunction errorToString(e: unknown): string {\n if (e instanceof Error) {\n return e.message;\n }\n return typeof e === 'string' ? e : JSON.stringify(e);\n}\n\nfunction reportError(text: string, e?: unknown): void {\n sendToHost({ cmd: 'error', error: e === undefined ? text : `${text}: ${errorToString(e)}` });\n}\n\nfunction remoteObjectToString(obj: Runtime.RemoteObject | undefined): string {\n if (!obj) {\n return '';\n }\n if (obj.value !== undefined) {\n return typeof obj.value === 'string' ? obj.value : JSON.stringify(obj.value);\n }\n return obj.unserializableValue || obj.description || obj.type;\n}\n\nfunction consoleTypeToSeverity(type: string | undefined): ioBroker.LogLevel {\n switch (type) {\n case 'warning':\n return 'warn';\n case 'error':\n case 'assert':\n return 'error';\n case 'debug':\n return 'debug';\n default:\n return 'info';\n }\n}\n\n/** Values like NaN, Infinity, -0 or BigInt cannot be transferred as JSON value */\nfunction toCallArgument(value: unknown): Runtime.CallArgument {\n if (typeof value === 'number' && (!Number.isFinite(value) || Object.is(value, -0))) {\n return { unserializableValue: Object.is(value, -0) ? '-0' : String(value) };\n }\n if (typeof value === 'bigint') {\n return { unserializableValue: `${value}n` };\n }\n return value === undefined ? {} : { value };\n}\n\nfunction isUrlOfFile(url: string, file: string): boolean {\n let path = url;\n if (url.startsWith('file://')) {\n try {\n path = fileURLToPath(url);\n } catch {\n return false;\n }\n }\n path = normalize(path);\n file = normalize(file);\n return process.platform === 'win32' ? path.toLowerCase() === file.toLowerCase() : path === file;\n}\n\nfunction createDomain(domain: string, client: InspectClientType): ProtocolDomain {\n return new Proxy<ProtocolDomain>(\n {},\n {\n get: (_target, method: string | symbol) =>\n // the object must not look like a promise\n typeof method === 'string' && method !== 'then'\n ? (params?: Record<string, unknown>): Promise<any> =>\n client.callMethod(`${domain}.${method}`, params)\n : undefined,\n },\n );\n}\n\nfunction runScript(\n script: string,\n scriptArgs: string[],\n childPrint: (text: string, isError?: boolean) => void,\n): Promise<[ChildProcessWithoutNullStreams, number, string]> {\n return new Promise((resolve, reject) => {\n // Always break on start: the process must not run before the debugger is connected, else it could\n // execute the `debugger;` statement of the script before. Port 0 means any free port.\n const child = spawn(process.execPath, ['--inspect-brk=127.0.0.1:0', normalize(script), ...scriptArgs]);\n child.stdout.setEncoding('utf8');\n child.stderr.setEncoding('utf8');\n child.stdout.on('data', (text: string) => childPrint(text));\n child.stderr.on('data', (text: string) => childPrint(text, true));\n\n let output = '';\n const timeout = setTimeout(() => {\n child.stderr.removeListener('data', waitForListenHint);\n child.kill();\n reject(new StartupError('Timeout by starting of the process to debug'));\n }, 10_000);\n\n function waitForListenHint(text: string): void {\n output += text;\n const res = /Debugger listening on ws:\\/\\/\\[?(.+?)]?:(\\d+)\\//.exec(output);\n if (res) {\n clearTimeout(timeout);\n child.stderr.removeListener('data', waitForListenHint);\n resolve([child, parseInt(res[2], 10), res[1]]);\n }\n }\n\n child.stderr.on('data', waitForListenHint);\n child.on('error', error => {\n clearTimeout(timeout);\n reject(new StartupError(`Cannot start the process to debug: ${error.message}`));\n });\n });\n}\n\nclass NodeInspector {\n readonly Debugger: ProtocolDomain;\n readonly Runtime: ProtocolDomain;\n\n private readonly client: InspectClientType = new InspectClient();\n private readonly file: string;\n private readonly args: string[];\n private child: ChildProcessWithoutNullStreams | null = null;\n /** The protocol does not deliver the URLs in the call frames anymore, so remember them */\n private readonly scriptUrls: Record<Runtime.ScriptId, string> = {};\n private mainScriptId: Runtime.ScriptId | undefined;\n private mainFile = '';\n private mainScriptSource: Promise<string> | null = null;\n /** Sometimes the first pause comes before the main script is parsed */\n private delayedContext: DebugEventParams | null = null;\n private pausedOnFirstLine = false;\n /** Execution context of the debugged script */\n private scriptContextId: number | undefined;\n private finished = false;\n\n constructor(file: string, args: string[]) {\n this.file = file;\n this.args = args;\n this.Debugger = createDomain('Debugger', this.client);\n this.Runtime = createDomain('Runtime', this.client);\n this.client.on('debugEvent', (fullName, params) => this.handleDebugEvent(fullName, params || {}));\n }\n\n async start(): Promise<void> {\n const [child, port, host] = await runScript(this.file, this.args, (text, isError) =>\n this.childPrint(text, isError),\n );\n this.child = child;\n child.on('exit', code => this.finish(`Process exited with code ${code}`));\n\n for (let attempt = 1; ; attempt++) {\n try {\n await this.client.connect(port, host);\n break;\n } catch (e) {\n debuglog(`Connection attempt #${attempt} failed: ${e as Error}`);\n if (attempt >= 10) {\n throw new StartupError(`Cannot connect to the debugger on ${host}:${port}`);\n }\n await new Promise(resolve => setTimeout(resolve, 500));\n }\n }\n\n await Promise.all([\n this.Runtime.enable(),\n this.Debugger.enable(),\n this.Debugger.setPauseOnExceptions({ state: 'none' }),\n this.Debugger.setAsyncCallStackDepth({ maxDepth: 1 }),\n this.Debugger.setBlackboxPatterns({ patterns: scriptToDebug ? SCRIPT_BLACKBOX_PATTERNS : [] }),\n this.Runtime.runIfWaitingForDebugger(),\n ]);\n }\n\n /** Kill the debugged process without waiting for it. Only for the exit handler, where nothing can be awaited */\n killChild(): void {\n this.client.reset();\n if (this.child) {\n this.child.kill();\n this.child = null;\n }\n }\n\n /**\n * Stop the debugged process and wait till it is really gone.\n *\n * The debugged process is started with `--debug`, so it writes its whole log to the stdout of this process, and it\n * logs while it is shutting down. If this process would end first, these pipes would be closed under it and every\n * further log line would fail with `EPIPE` - which the adapter reports as an uncaught exception and dies (#2382).\n */\n async stopChild(timeoutMs = 3_000): Promise<void> {\n this.client.reset();\n const child = this.child;\n this.child = null;\n if (!child || child.exitCode !== null || child.signalCode !== null) {\n return;\n }\n await new Promise<void>(resolve => {\n const timeout = setTimeout(() => {\n // It does not want to end - take the hard way\n child.kill('SIGKILL');\n resolve();\n }, timeoutMs);\n\n child.once('exit', () => {\n clearTimeout(timeout);\n resolve();\n });\n\n child.kill();\n });\n }\n\n private finish(reason: string): void {\n if (this.finished) {\n return;\n }\n this.finished = true;\n debuglog(reason);\n sendToHost({ cmd: 'finished', text: reason });\n void endInspector(0);\n }\n\n private childPrint(text: string, isError?: boolean): void {\n if (isError) {\n const lines = text\n .split(/\\r\\n|\\r|\\n/g)\n .filter(line => !!line)\n .map(line => `< ${line}`);\n lines.length && process.stdout.write(`${lines.join('\\n')}\\n`);\n }\n // The debugged process ended, but it waits till the debugger disconnects\n if (text.includes('Waiting for the debugger to disconnect')) {\n this.finish('Process finished');\n }\n }\n\n private handleDebugEvent(fullName: string, params: DebugEventParams): void {\n switch (fullName) {\n case 'Debugger.scriptParsed':\n this.onScriptParsed(params);\n break;\n\n case 'Debugger.paused':\n this.onPaused(params);\n break;\n\n case 'Debugger.resumed':\n sendToHost({ cmd: 'resumed', context: params });\n break;\n\n case 'Runtime.consoleAPICalled':\n this.onConsoleApiCalled(params);\n break;\n\n case 'Runtime.executionContextCreated':\n // main.ts gives the context of a script the name of the script\n if (scriptToDebug && params.context?.name === scriptToDebug) {\n this.scriptContextId = params.context.id;\n }\n break;\n\n case 'Runtime.executionContextDestroyed':\n if (params.executionContextId === 1) {\n // the main context of the debugged process is gone\n this.finish('Process finished');\n } else if (this.scriptContextId !== undefined && params.executionContextId === this.scriptContextId) {\n // the script was stopped, but the process is still running\n sendToHost({ cmd: 'finished', context: params });\n }\n break;\n\n default:\n debuglog(`${fullName}: ${JSON.stringify(params)}`);\n break;\n }\n }\n\n private onScriptParsed(params: DebugEventParams): void {\n const { scriptId, url } = params;\n if (!scriptId || !url) {\n return;\n }\n this.scriptUrls[scriptId] = url;\n\n const isMain = scriptToDebug ? url === scriptToDebug : !!instanceToDebug && isUrlOfFile(url, instanceToDebug);\n if (!isMain) {\n return;\n }\n debuglog(`Script to debug parsed: ${scriptId}`);\n this.mainScriptId = scriptId;\n this.mainFile = url.replace('file:///', '');\n this.mainScriptSource = this.Debugger.getScriptSource({ scriptId }).then(\n (result: Debugger.GetScriptSourceReturnType) => result.scriptSource,\n );\n\n if (this.delayedContext) {\n const context = this.delayedContext;\n this.delayedContext = null;\n void this.sendReadyToDebug(context);\n }\n }\n\n private onPaused(params: DebugEventParams): void {\n if (!this.pausedOnFirstLine) {\n if (params.reason === 'Break on start' && !breakOnStart) {\n // the process was started with --inspect-brk only to have time to set up the debugger\n this.Debugger.resume().catch(e => reportError('Cannot resume', e));\n return;\n }\n if (params.reason === 'exception') {\n // ignore all exceptions till the start of the script\n this.Debugger.resume().catch(e => reportError('Cannot resume', e));\n return;\n }\n }\n\n this.enrichCallFrames(params);\n\n if (\n this.pausedOnFirstLine &&\n scriptToDebug &&\n params.reason === 'step' &&\n !params.callFrames?.[0]?.url?.startsWith('script.js.')\n ) {\n // Stepping left the script, e.g., at the end of a callback. The blackbox patterns do not cover\n // all internals of node.js, so continue the execution instead of stopping there\n this.Debugger.resume().catch(e => reportError('Cannot resume', e));\n return;\n }\n\n if (this.pausedOnFirstLine) {\n sendToHost({ cmd: 'paused', context: params });\n } else {\n this.pausedOnFirstLine = true;\n if (this.mainScriptSource) {\n void this.sendReadyToDebug(params);\n } else {\n // store the context to send it, when the main script is parsed\n this.delayedContext = params;\n }\n }\n }\n\n private async sendReadyToDebug(context: DebugEventParams): Promise<void> {\n try {\n const script = await this.mainScriptSource;\n this.enrichCallFrames(context);\n sendToHost({\n cmd: 'readyToDebug',\n scriptId: this.mainScriptId,\n script,\n context,\n url: this.mainFile,\n });\n } catch (e) {\n reportError('Cannot read the source of the script to debug', e);\n }\n }\n\n private enrichCallFrames(context: DebugEventParams): void {\n context.callFrames?.forEach(frame => {\n if (!frame.url) {\n frame.url = this.scriptUrls[frame.location.scriptId] || '';\n }\n });\n }\n\n private onConsoleApiCalled(params: DebugEventParams): void {\n const args = params.args || [];\n if (instanceToDebug) {\n sendToHost({\n cmd: 'log',\n severity: consoleTypeToSeverity(params.type),\n text: args.map(arg => remoteObjectToString(arg)).join(' '),\n ts: Date.now(),\n });\n return;\n }\n\n // The sandbox logs in debug mode as `console.log(`${severity}$$${scriptName}$$${message}`, Date.now())`\n const text = remoteObjectToString(args[0]);\n const marker = `$$${scriptToDebug}$$`;\n const pos = text.indexOf(marker);\n if (pos !== -1) {\n sendToHost({\n cmd: 'log',\n severity: text.substring(0, pos),\n text: text.substring(pos + marker.length),\n ts: typeof args[1]?.value === 'number' ? args[1].value : Date.now(),\n });\n } else if (params.type === 'warning' || params.type === 'error') {\n sendToHost({\n cmd: 'log',\n severity: consoleTypeToSeverity(params.type),\n text: args.map(arg => remoteObjectToString(arg)).join(' '),\n ts: Date.now(),\n });\n }\n }\n}\n\nfunction resolveAdapterMainFile(adapter: string): string | undefined {\n try {\n return require.resolve(`iobroker.${adapter}`);\n } catch {\n // try to locate it in the same node_modules directory as this adapter\n const dir = normalize(join(__dirname, '..', '..', '..', `iobroker.${adapter}`));\n if (existsSync(join(dir, 'package.json'))) {\n try {\n const pack = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));\n const main = join(dir, pack.main || `${adapter}.js`);\n if (existsSync(main)) {\n return main;\n }\n } catch {\n // ignore\n }\n }\n }\n return undefined;\n}\n\nfunction startDebugging(data: DebugCommand): void {\n if (inspector) {\n reportError('The debugger is already started');\n return;\n }\n\n if (data.scriptName) {\n scriptToDebug = data.scriptName;\n inspector = new NodeInspector(join(__dirname, '..', 'main.js'), [\n (data.instance || 0).toString(),\n '--debug',\n '--debugScript',\n scriptToDebug,\n ]);\n } else {\n const [adapter, instance] = (data.adapterInstance || '').split('.');\n const file = resolveAdapterMainFile(adapter);\n if (!file) {\n reportError(`Cannot locate iobroker.${adapter}`);\n setTimeout(() => {\n sendToHost({ cmd: 'finished', context: `Cannot locate iobroker.${adapter}` });\n setTimeout(() => process.exit(0), 500);\n }, 200);\n return;\n }\n instanceToDebug = file;\n inspector = new NodeInspector(file, [instance || '0', '--debug']);\n }\n\n inspector.start().catch((e: unknown) => {\n reportError(\n e instanceof StartupError\n ? e.message\n : `Internal error in inspector: ${e instanceof Error ? e.stack : errorToString(e)}`,\n );\n void endInspector(1);\n });\n}\n\nasync function processCommand(data: DebugCommand): Promise<void> {\n debuglog(`processCommand: ${JSON.stringify(data)}`);\n\n if (data.cmd === 'start') {\n startDebugging(data);\n return;\n }\n if (data.cmd === 'end') {\n await endInspector(0);\n return;\n }\n if (!inspector) {\n reportError(`Cannot process \"${data.cmd}\": the debugger is not started`);\n return;\n }\n const { Debugger, Runtime } = inspector;\n\n switch (data.cmd) {\n case 'source':\n try {\n const { scriptSource } = (await Debugger.getScriptSource({\n scriptId: data.scriptId,\n })) as Debugger.GetScriptSourceReturnType;\n sendToHost({ cmd: 'script', scriptId: data.scriptId, text: scriptSource });\n } catch (e) {\n reportError(`Cannot read the source of script ${data.scriptId}`, e);\n }\n break;\n\n case 'cont':\n case 'next':\n case 'step':\n case 'out':\n case 'pause': {\n const method = { cont: 'resume', next: 'stepOver', step: 'stepInto', out: 'stepOut', pause: 'pause' }[\n data.cmd\n ];\n try {\n await Debugger[method]();\n } catch (e) {\n reportError(`Cannot execute \"${data.cmd}\"`, e);\n }\n break;\n }\n\n case 'sb': {\n const breakpoints = await Promise.all(\n ((data.breakpoints || []) as Debugger.Location[]).map(async bp => {\n try {\n const result = (await Debugger.setBreakpoint({\n location: {\n scriptId: bp.scriptId,\n lineNumber: bp.lineNumber,\n columnNumber: bp.columnNumber,\n },\n })) as Debugger.SetBreakpointReturnType;\n return { id: result.breakpointId, location: result.actualLocation };\n } catch (e) {\n reportError(`Cannot set breakpoint on line ${bp.lineNumber + 1}`, e);\n return null;\n }\n }),\n );\n sendToHost({ cmd: 'sb', breakpoints: breakpoints.filter(bp => bp) });\n break;\n }\n\n case 'cb': {\n const breakpointIds = await Promise.all(\n ((data.breakpoints || []) as Debugger.BreakpointId[]).map(async breakpointId => {\n try {\n await Debugger.removeBreakpoint({ breakpointId });\n } catch (e) {\n // The breakpoint does not exist (anymore), so it is removed anyway\n debuglog(`Cannot clear breakpoint ${breakpointId}: ${e as Error}`);\n }\n return breakpointId;\n }),\n );\n sendToHost({ cmd: 'cb', breakpoints: breakpointIds });\n break;\n }\n\n case 'scope': {\n const scopes = await Promise.all(\n (data.scopes || [])\n .filter(scope => scope?.object?.objectId)\n .map(async scope => {\n try {\n const properties = (await Runtime.getProperties({\n objectId: scope.object.objectId,\n generatePreview: true,\n })) as Runtime.GetPropertiesReturnType;\n return { type: scope.type, name: scope.name, index: scope.index, properties };\n } catch (e) {\n // e.g., the execution was resumed in the meantime\n debuglog(`Cannot read scope: ${e as Error}`);\n return null;\n }\n }),\n );\n sendToHost({ cmd: 'scope', scopes: scopes.filter(scope => scope) });\n break;\n }\n\n case 'setValue':\n try {\n await Debugger.setVariableValue({\n variableName: data.variableName,\n scopeNumber: data.scopeNumber,\n newValue: toCallArgument(data.newValue?.value),\n callFrameId: data.callFrameId,\n });\n sendToHost({\n cmd: 'setValue',\n variableName: data.variableName,\n scopeNumber: data.scopeNumber,\n newValue: data.newValue,\n callFrameId: data.callFrameId,\n });\n } catch (e) {\n reportError(`Cannot set value of \"${data.variableName}\"`, e);\n }\n break;\n\n case 'expressions': {\n const expressions = await Promise.all(\n (data.expressions || []).map(async item => {\n try {\n const { result } = (await Debugger.evaluateOnCallFrame({\n callFrameId: data.callFrameId,\n expression: item.name,\n objectGroup: 'node-inspect',\n generatePreview: true,\n })) as Debugger.EvaluateOnCallFrameReturnType;\n return { name: item.name, result };\n } catch (e) {\n return {\n name: item.name,\n result: {\n type: 'object',\n subtype: 'error',\n className: 'Error',\n description: errorToString(e),\n },\n };\n }\n }),\n );\n sendToHost({ cmd: 'expressions', expressions });\n break;\n }\n\n case 'stopOnException':\n try {\n await Debugger.setPauseOnExceptions({ state: data.state ? 'all' : 'none' });\n } catch (e) {\n reportError('Cannot change \"stop on exception\"', e);\n }\n break;\n\n case 'getPossibleBreakpoints':\n try {\n const { locations } = (await Debugger.getPossibleBreakpoints({\n start: data.start,\n end: data.end,\n })) as Debugger.GetPossibleBreakpointsReturnType;\n sendToHost({ cmd: 'getPossibleBreakpoints', breakpoints: locations });\n } catch (e) {\n reportError('Cannot get possible breakpoints', e);\n }\n break;\n\n default:\n console.error(`[DEBUGGER] Unknown command: ${JSON.stringify(data)}`);\n break;\n }\n}\n\nprocess.on('message', (message: unknown): void => {\n let command: DebugCommand;\n try {\n command = typeof message === 'string' ? (JSON.parse(message) as DebugCommand) : (message as DebugCommand);\n } catch {\n console.error(`[DEBUGGER] Cannot parse: ${JSON.stringify(message)}`);\n return;\n }\n processCommand(command).catch(e => reportError(`Cannot process \"${command?.cmd}\"`, e));\n});\n\n// A closed pipe of the own output (the host can be gone already) must not end the inspector with an EPIPE\nprocess.stdout.on('error', () => {});\nprocess.stderr.on('error', () => {});\n\n// Handle all possible exits and never leave the debugged process behind\nprocess.on('exit', () => inspector?.killChild());\nprocess.on('disconnect', () => void endInspector(0));\nprocess.once('SIGTERM', () => void endInspector(0));\nprocess.once('SIGHUP', () => void endInspector(0));\nprocess.on('uncaughtException', (e: NodeJS.ErrnoException) => {\n // The connection to the debugged process is reset as soon as it ends (node-inspect's client does not listen for\n // that), and while the inspector is on its way out, there is nothing worth reporting anymore\n if (ending || e?.code === 'ECONNRESET' || e?.code === 'EPIPE') {\n debuglog(`Ignored error in the inspector: ${e?.stack || e?.message}`);\n void endInspector(0);\n return;\n }\n reportError(`Internal error in inspector: ${e.stack || e.message}`);\n void endInspector(1);\n});\n\nsendToHost({ cmd: 'ready' });\n"]}
@@ -461,7 +461,16 @@ class Mirror {
461
461
  this.dbList[id].ts = ts;
462
462
  this.log.debug(`Update script ${id} in DB`);
463
463
  this.dbList[id].from = this.from;
464
- void this.adapter.setForeignObject(id, this.dbList[id]);
464
+ /*
465
+ * Only the source. Writing the whole cached object would carry everything
466
+ * else in it back into the database as well, and a file says nothing about
467
+ * whether its script is enabled or which instance runs it (#2396). Together
468
+ * with the cache being kept in step above this holds even when the object
469
+ * changes while a write is on its way.
470
+ */
471
+ void this.adapter.extendForeignObject(id, {
472
+ common: { source },
473
+ });
465
474
  }
466
475
  else {
467
476
  this.dbList[id].ts = ts;
@@ -542,28 +551,20 @@ class Mirror {
542
551
  }
543
552
  }
544
553
  else if (obj.type === 'script' && id.startsWith('script.js.')) {
545
- if (this.dbList[id]) {
546
- // File changed
547
- if (this.dbList[id].common.source !== obj.common.source) {
548
- this.dbList[id] = obj;
549
- this.log.debug(`Update ${file} on disk`);
550
- this.diskList[id] = { ts: 0, source: obj.common.source, name: file };
551
- this._writeFile(id);
552
- }
553
- else if (!this.diskList[id] || this.diskList[id].source !== obj.common.source) {
554
- this.log.debug(`Update ${file} on disk`);
555
- this.diskList[id] = { ts: 0, source: obj.common.source, name: file };
556
- this._writeFile(id);
557
- }
558
- }
559
- else {
560
- // new script
561
- this.dbList[id] = obj;
562
- if (!this.diskList[id] || this.diskList[id].source !== obj.common.source) {
563
- this.log.debug(`Create ${file} on disk`);
564
- this.diskList[id] = { ts: 0, source: obj.common.source, name: file };
565
- this._writeFile(id);
566
- }
554
+ const known = this.dbList[id];
555
+ /*
556
+ * The cache follows *every* change of the object, not only one that touched the source.
557
+ * It used to be refreshed only on a changed source, so enabling a script in the admin or
558
+ * moving it to another instance left a stale copy here - and the next change of the file
559
+ * on disk wrote that copy back, which silently disabled the script again and pulled it
560
+ * back to its old instance (#2396).
561
+ */
562
+ this.dbList[id] = obj;
563
+ const sourceChanged = !known || known.common.source !== obj.common.source;
564
+ if (sourceChanged || !this.diskList[id] || this.diskList[id].source !== obj.common.source) {
565
+ this.log.debug(`${known ? 'Update' : 'Create'} ${file} on disk`);
566
+ this.diskList[id] = { ts: 0, source: obj.common.source, name: file };
567
+ this._writeFile(id);
567
568
  }
568
569
  this.dbList[id].ts = Date.now();
569
570
  }