fix: keep MCP transport alive when stdin closes
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user