@ian2018cs/agenthub 0.1.72 → 0.1.73
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 +1 -1
- package/server/index.js +21 -0
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -32,6 +32,27 @@ const c = {
|
|
|
32
32
|
|
|
33
33
|
console.log('PORT from env:', process.env.PORT);
|
|
34
34
|
|
|
35
|
+
// 全局兜底:防止 SDK 内部异步异常(如中止 session 时 stream 已关闭导致的 "Operation aborted")crash 进程
|
|
36
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
37
|
+
const msg = reason?.message || String(reason);
|
|
38
|
+
if (msg.includes('Operation aborted') || msg.includes('operation aborted')) {
|
|
39
|
+
// Claude Agent SDK 在 session 被中止后内部写 stream 引发,属预期行为,仅记录 debug 日志
|
|
40
|
+
console.debug('[unhandledRejection] SDK operation aborted (expected on session stop):', msg);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
console.error('[unhandledRejection]', reason);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
process.on('uncaughtException', (err) => {
|
|
47
|
+
const msg = err?.message || String(err);
|
|
48
|
+
if (msg.includes('Operation aborted') || msg.includes('operation aborted')) {
|
|
49
|
+
console.debug('[uncaughtException] SDK operation aborted (expected on session stop):', msg);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
console.error('[uncaughtException]', err);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|
|
55
|
+
|
|
35
56
|
import express from 'express';
|
|
36
57
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
37
58
|
import os from 'os';
|