livedesk 0.1.442 → 0.1.444

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.197",
3
+ "version": "0.1.199",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,10 +41,10 @@
41
41
  "ws": "^8.18.3"
42
42
  },
43
43
  "optionalDependencies": {
44
- "@livedesk/fast-linux-x64": "0.1.404",
45
- "@livedesk/fast-osx-arm64": "0.1.404",
46
- "@livedesk/fast-osx-x64": "0.1.404",
47
- "@livedesk/fast-win-x64": "0.1.404"
44
+ "@livedesk/fast-linux-x64": "0.1.406",
45
+ "@livedesk/fast-osx-arm64": "0.1.406",
46
+ "@livedesk/fast-osx-x64": "0.1.406",
47
+ "@livedesk/fast-win-x64": "0.1.406"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"
@@ -33,6 +33,18 @@ function isOwnedUnixProcessGroupAlive(child, platform, signalProcess) {
33
33
  }
34
34
  }
35
35
 
36
+ function isProcessIdAlive(processId, signalProcess) {
37
+ if (!Number.isInteger(processId) || processId <= 1) {
38
+ return false;
39
+ }
40
+ try {
41
+ signalProcess(processId, 0);
42
+ return true;
43
+ } catch (error) {
44
+ return error?.code === 'EPERM';
45
+ }
46
+ }
47
+
36
48
  function signalAgentTree(child, signal, platform, signalProcess) {
37
49
  const processId = Number(child?.pid || 0);
38
50
  if (platform !== 'win32'
@@ -56,6 +68,9 @@ export function installAgentTerminationHandlers({
56
68
  platform = process.platform,
57
69
  signalProcess = (pid, signal) => process.kill(pid, signal),
58
70
  terminateWindowsTree = terminateWindowsProcessTree,
71
+ windowsTerminateAttemptLimit = 3,
72
+ windowsTerminateRetryMs = 100,
73
+ reportTerminationFailure = message => console.error(message),
59
74
  exitProcess = code => hostProcess.exit(code)
60
75
  } = {}) {
61
76
  if (typeof getAgentProcess !== 'function') {
@@ -79,12 +94,14 @@ export function installAgentTerminationHandlers({
79
94
  let poll = null;
80
95
  let timeout = null;
81
96
  let hardStop = null;
97
+ let windowsRetryTimer = null;
82
98
  const finish = () => {
83
99
  if (finished) return;
84
100
  finished = true;
85
101
  if (poll) clearInterval(poll);
86
102
  if (timeout) clearTimeout(timeout);
87
103
  if (hardStop) clearTimeout(hardStop);
104
+ if (windowsRetryTimer) clearTimeout(windowsRetryTimer);
88
105
  exitProcess(exitCode);
89
106
  };
90
107
  const processId = Number(child?.pid || 0);
@@ -99,16 +116,52 @@ export function installAgentTerminationHandlers({
99
116
  // alive until taskkill has completed against this exact,
100
117
  // launcher-owned process tree. Never search for or terminate
101
118
  // unrelated ffmpeg.exe processes globally.
102
- let treeTermination;
103
- try {
104
- treeTermination = terminateWindowsTree(processId);
105
- } catch {
106
- finish();
107
- return;
108
- }
109
- Promise.resolve(treeTermination)
110
- .catch(() => null)
111
- .finally(finish);
119
+ const attemptLimit = Math.max(1, Number(windowsTerminateAttemptLimit) || 3);
120
+ const retryMs = Math.max(25, Number(windowsTerminateRetryMs) || 100);
121
+ let attempt = 0;
122
+ let failureReported = false;
123
+ const terminateOwnedTree = () => {
124
+ if (finished) return;
125
+ attempt += 1;
126
+ let treeTermination;
127
+ try {
128
+ treeTermination = terminateWindowsTree(processId);
129
+ } catch (error) {
130
+ treeTermination = { ok: false, error };
131
+ }
132
+ Promise.resolve(treeTermination)
133
+ .catch(error => ({ ok: false, error }))
134
+ .then(result => {
135
+ if (finished) return;
136
+ if (result?.ok !== false) {
137
+ finish();
138
+ return;
139
+ }
140
+ if (!isProcessIdAlive(processId, signalProcess)) {
141
+ finish();
142
+ return;
143
+ }
144
+
145
+ const burstExhausted = attempt >= attemptLimit;
146
+ if (burstExhausted && !failureReported) {
147
+ failureReported = true;
148
+ const reason = result?.error?.message || 'taskkill returned an error';
149
+ reportTerminationFailure(
150
+ `[LiveDesk Client] Agent tree pid=${processId} is still alive after `
151
+ + `${attemptLimit} exact-PID taskkill attempts (${reason}). `
152
+ + 'The launcher will remain alive and keep retrying so capture descendants are not orphaned.'
153
+ );
154
+ }
155
+ if (burstExhausted) {
156
+ attempt = 0;
157
+ }
158
+ windowsRetryTimer = setTimeout(
159
+ terminateOwnedTree,
160
+ burstExhausted ? Math.max(1000, retryMs) : retryMs
161
+ );
162
+ });
163
+ };
164
+ terminateOwnedTree();
112
165
  return;
113
166
  }
114
167
  const finishWhenTreeStops = () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "livedesk",
3
- "version": "0.1.442",
4
- "livedeskClientVersion": "0.1.197",
3
+ "version": "0.1.444",
4
+ "livedeskClientVersion": "0.1.199",
5
5
  "buildFlavor": "production",
6
6
  "description": "LiveDesk Hub and client launcher",
7
7
  "type": "module",
@@ -50,10 +50,10 @@
50
50
  "ws": "^8.18.3"
51
51
  },
52
52
  "optionalDependencies": {
53
- "@livedesk/fast-linux-x64": "0.1.404",
54
- "@livedesk/fast-osx-arm64": "0.1.404",
55
- "@livedesk/fast-osx-x64": "0.1.404",
56
- "@livedesk/fast-win-x64": "0.1.404"
53
+ "@livedesk/fast-linux-x64": "0.1.406",
54
+ "@livedesk/fast-osx-arm64": "0.1.406",
55
+ "@livedesk/fast-osx-x64": "0.1.406",
56
+ "@livedesk/fast-win-x64": "0.1.406"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public"