claw-subagent-service 0.0.49 → 0.0.51
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
|
@@ -111,8 +111,13 @@ function getGatewayToken() {
|
|
|
111
111
|
if (fs.existsSync(filePath)) {
|
|
112
112
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
113
113
|
const config = JSON.parse(content);
|
|
114
|
-
// 可能的 token
|
|
115
|
-
const token = config.gatewayToken
|
|
114
|
+
// 可能的 token 字段名(支持嵌套路径 gateway.auth.token)
|
|
115
|
+
const token = config.gatewayToken
|
|
116
|
+
|| (config.gateway?.auth?.token)
|
|
117
|
+
|| config.token
|
|
118
|
+
|| config.apiKey
|
|
119
|
+
|| config.api_key
|
|
120
|
+
|| config.password;
|
|
116
121
|
if (token) {
|
|
117
122
|
return String(token);
|
|
118
123
|
}
|
|
@@ -302,7 +307,12 @@ class OpenClawClient {
|
|
|
302
307
|
const text = chunk.toString();
|
|
303
308
|
stderr += text;
|
|
304
309
|
// 实时记录 stderr,方便调试卡死问题
|
|
305
|
-
|
|
310
|
+
// 子进程退出时管道可能已断开,忽略 EPIPE 避免未捕获异常
|
|
311
|
+
try {
|
|
312
|
+
this.log?.info(`[OpenClawClient] CLI stderr: ${text.trim().substring(0, 300)}`);
|
|
313
|
+
} catch {
|
|
314
|
+
// 忽略日志写入失败
|
|
315
|
+
}
|
|
306
316
|
});
|
|
307
317
|
|
|
308
318
|
// 超时兜底(30 分钟)
|
package/service/worker.js
CHANGED
|
@@ -21,7 +21,15 @@ const HOST = process.env.SILENT_SERVICE_HOST || '127.0.0.1';
|
|
|
21
21
|
// 如果 logger 初始化后,也同步写到 logger
|
|
22
22
|
const originalStderr = process.stderr.write.bind(process.stderr);
|
|
23
23
|
process.stderr.write = (chunk, encoding, callback) => {
|
|
24
|
-
|
|
24
|
+
try {
|
|
25
|
+
originalStderr(chunk, encoding, callback);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
// EPIPE 常见于子进程(如 openclaw)已退出但仍在写日志,忽略即可
|
|
28
|
+
if (err.code === 'EPIPE') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
25
33
|
};
|
|
26
34
|
|
|
27
35
|
/**
|
|
@@ -566,6 +574,11 @@ process.on('uncaughtException', async (err) => {
|
|
|
566
574
|
log.warn(`[WORKER] 捕获到 EADDRINUSE(端口 ${PORT}),交由 server 错误处理器重试`);
|
|
567
575
|
return;
|
|
568
576
|
}
|
|
577
|
+
// EPIPE 常见于子进程(如 openclaw)已退出但仍在写日志,不触发整个 worker 关闭
|
|
578
|
+
if (err.code === 'EPIPE') {
|
|
579
|
+
log.warn(`[WORKER] 捕获到 EPIPE(子进程管道断开),忽略`);
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
569
582
|
log.error(`[WORKER] 未捕获异常: ${err.message}\n${err.stack}`);
|
|
570
583
|
if (!isShuttingDown) {
|
|
571
584
|
await gracefulShutdown('uncaughtException');
|