@nowcrew/daemon 0.6.97-beta.7 → 0.6.97-beta.8
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.
|
@@ -3,7 +3,7 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
3
3
|
import { MACHINE_ENVIRONMENT_MAX_BYTES, MachineEnvironmentCaptureError } from "./machine-environment-contract.js";
|
|
4
4
|
/** 只接收本模块 detached spawn 所创建的进程组,绝不复用 supervisor 的 PID 清理接口。 */
|
|
5
5
|
async function cleanupOwnedGroup(pid) {
|
|
6
|
-
const exists = () => {
|
|
6
|
+
const exists = async () => {
|
|
7
7
|
try {
|
|
8
8
|
process.kill(-pid, 0);
|
|
9
9
|
return true;
|
|
@@ -11,6 +11,22 @@ async function cleanupOwnedGroup(pid) {
|
|
|
11
11
|
catch (error) {
|
|
12
12
|
if (error.code === "ESRCH")
|
|
13
13
|
return false;
|
|
14
|
+
if (process.platform === "darwin" && error.code === "EPERM") {
|
|
15
|
+
// macOS may briefly return EPERM while the exited group is being reaped.
|
|
16
|
+
// Only confirmed absence clears this state; never signal an uncertain group.
|
|
17
|
+
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
18
|
+
await delay(20);
|
|
19
|
+
try {
|
|
20
|
+
process.kill(-pid, 0);
|
|
21
|
+
}
|
|
22
|
+
catch (probeError) {
|
|
23
|
+
if (probeError.code === "ESRCH")
|
|
24
|
+
return false;
|
|
25
|
+
if (probeError.code !== "EPERM")
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
throw new MachineEnvironmentCaptureError("shell_cleanup_failed");
|
|
15
31
|
}
|
|
16
32
|
};
|
|
@@ -23,14 +39,14 @@ async function cleanupOwnedGroup(pid) {
|
|
|
23
39
|
throw new MachineEnvironmentCaptureError("shell_cleanup_failed");
|
|
24
40
|
}
|
|
25
41
|
};
|
|
26
|
-
if (!exists())
|
|
42
|
+
if (!await exists())
|
|
27
43
|
return;
|
|
28
44
|
for (const value of ["SIGTERM", "SIGKILL"]) {
|
|
29
45
|
signal(value);
|
|
30
46
|
const until = Date.now() + 1_000;
|
|
31
|
-
while (exists() && Date.now() < until)
|
|
47
|
+
while (await exists() && Date.now() < until)
|
|
32
48
|
await delay(20);
|
|
33
|
-
if (!exists())
|
|
49
|
+
if (!await exists())
|
|
34
50
|
return;
|
|
35
51
|
}
|
|
36
52
|
throw new MachineEnvironmentCaptureError("shell_cleanup_failed");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nowcrew/daemon",
|
|
3
|
-
"version": "0.6.97-beta.
|
|
3
|
+
"version": "0.6.97-beta.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@agentclientprotocol/sdk": "1.2.1",
|
|
23
|
-
"@nowcrew/cli": "0.4.
|
|
23
|
+
"@nowcrew/cli": "0.4.18",
|
|
24
24
|
"cross-spawn": "^7.0.6",
|
|
25
25
|
"semver": "7.8.5",
|
|
26
26
|
"smol-toml": "1.8.0",
|