@livedesk/client 0.1.197 → 0.1.199
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livedesk/client",
|
|
3
|
-
"version": "0.1.
|
|
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.
|
|
45
|
-
"@livedesk/fast-osx-arm64": "0.1.
|
|
46
|
-
"@livedesk/fast-osx-x64": "0.1.
|
|
47
|
-
"@livedesk/fast-win-x64": "0.1.
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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 = () => {
|