fix: keep MCP transport alive when stdin closes

This commit is contained in:
卡若AI
2026-06-26 20:51:03 +08:00
parent 7d1815d6c9
commit 22e5611c94

View File

@@ -1112,9 +1112,12 @@ rl.on('line', async (line) => {
/** Cursor 可能关闭 MCP stdin挂起 poll 期间禁止 exit否则 Hub 仍 waiting 但无 poller */
let activeWaitToken = null;
let idleKeepAliveTimer = null;
process.stdin.on('end', () => {
log('stdin end', { activeWait: activeWaitToken });
if (!activeWaitToken) setTimeout(() => process.exit(0), 200);
if (activeWaitToken) return;
if (!idleKeepAliveTimer) idleKeepAliveTimer = setInterval(() => {}, 60 * 1000);
log('stdin end ignored: keep alive while idle to preserve transport');
});
process.on('SIGTERM', () => process.exit(0));