fix(maker): prevent orphan proxy processes#252
Merged
Conversation
- Add Maker lifecycle guards for stdin close, parent death, and stdio disconnects. - Close tracked child transports when the Maker MCP server exits. - Close stale proxy clients before reconnecting to avoid transport leaks. - Report PPID=1 Maker orphan processes in doctor without killing them. - Keep long-running sessions alive by avoiding idle TTL or max lifetime kills. - Separate local AI development docs from public Maker documentation. Verification: - npm run build - npm run lint - npm run format:check - npm test -- --runInBand
- Increase Maker clone/fetch retry budget from 2 to 3 retries. - Change default retry base delay from 1500ms to 10000ms. - Give Maker repositories more time to finish server-side preparation. - Cover retry count and default delay with clone binding tests. - Update Maker docs for the new retry behavior and env override default. Verification: - npm test -- --runTestsByPath src/__tests__/makerCloneBinding.test.ts --runInBand - npm run lint - npm run format:check - npm run build - npm test -- --runInBand
- Increase Maker clone/fetch retry budget from 3 to 5 retries. - Change default retry base delay from 10000ms to 5000ms. - Update clone binding tests for retry count and delay defaults. - Update Maker docs for the new retry policy. Verification: - npm test -- --runTestsByPath src/__tests__/makerCloneBinding.test.ts --runInBand - npm run lint - npm run format:check - npm run build - npm test -- --runInBand
|
| Filename | Overview |
|---|---|
| src/maker/lifecycle.ts | 新增进程生命周期守卫模块:stdin EOF 处理、父进程死亡检测、stdio 断连错误识别,逻辑正确,单元测试完整。 |
| src/maker/server/childTransports.ts | 新增 transport 注册表,用于追踪和批量关闭活跃子进程 transport;幂等关闭和 Set 操作逻辑正确。 |
| src/mcp-proxy/proxy.ts | 新增指数退避、stale client 关闭、healthCheckTimer.unref();reconnectDelayMs 字段初始化硬编码为默认值,忽略用户配置,导致首次重连延迟可能与预期不符。 |
| src/maker/server/mcp.ts | 所有 StdioClientTransport 实例均通过 trackMakerChildTransport 注册;新增 installMakerServerExitHandlers 在 stdin 关闭/信号时关闭子 transport,3 秒超时兜底,逻辑完备。 |
| src/maker/index.ts | 添加 stdin EOF 处理、父进程死亡看门狗、stdio EPIPE 防护和 safeWriteStderr,正确处理递归错误场景。 |
| src/maker/cli/commands.ts | doctor 命令新增孤儿进程检测和 MCP tools 可见性诊断;ps 输出解析逻辑、PPID=1 过滤和 logs watch 排除均正确。 |
| src/maker/cli/projects.ts | Git 重试上限从 2 次提升至 5 次,基础延迟从 1500ms 调整为 5000ms,函数改为 export 以便测试覆盖。 |
| src/tests/makerLifecycle.test.ts | 新增生命周期测试,覆盖 stdio 断连判断、父进程死亡检测、stale client 关闭、reconnectDelayMs 重置和 stdin EOF 退出路径。 |
Sequence Diagram
sequenceDiagram
participant AI as AI Client
participant MCP as Maker MCP Server
participant CT as childTransports registry
participant Proxy as __maker-proxy (embedded)
AI->>MCP: spawn (stdio)
MCP->>MCP: installMakerServerExitHandlers()
MCP->>Proxy: spawn (StdioClientTransport)
MCP->>CT: trackMakerChildTransport(transport)
Proxy->>Proxy: installProxyStdinExitHandler()
Proxy->>Proxy: installParentDeathWatchdog(15s interval)
Note over AI,Proxy: Normal operation
AI->>MCP: stdin closes (client exit / EPIPE)
MCP->>MCP: shutdown() [exiting guard]
MCP->>CT: closeTrackedMakerChildTransports()
CT->>Proxy: transport.close()
Note over MCP: 3s timeout race
MCP->>MCP: process.exit(0)
Note over Proxy: Independent watchdog path
Proxy->>Proxy: "watchdog: process.ppid == 1?"
Proxy->>Proxy: proxy.cleanup() + process.exit(0)
Reviews (3): Last reviewed commit: "fix(proxy): honor configured reconnect i..." | Re-trigger Greptile
- Add doctor output for Maker MCP tools availability. - Guide users to restart or open a new AI conversation when tools are missing. - Warn when the AI pwd does not match the Maker project directory. - Cover the new doctor guidance with CLI tests and docs. Validation: - npx jest src/__tests__/makerCliCommands.test.ts --runInBand - npm run build - npm run lint
- Reset successful reconnect delay to the configured reconnect interval. - Add a lifecycle test covering custom reconnect_interval recovery. - Simplify Maker orphan process command matching after logs watch filtering. Validation: - npx jest src/__tests__/makerLifecycle.test.ts --runInBand - npx jest src/__tests__/makerCliCommands.test.ts --runInBand - npm run build - npm run lint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动内容
影响面
Verification