fix: close idle HTTP connections to prevent process hanging on exit#4
Conversation
The GitLab SDK's underlying go-retryablehttp maintains idle HTTP connections. Without explicitly closing them, the process hangs after command completion waiting for connection timeouts. Added CloseIdleConnections() to GitLabClient and defer-called it in all command functions to ensure immediate cleanup on exit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
alaudabot
left a comment
There was a problem hiding this comment.
Review Summary
This PR correctly addresses the CLI hang issue by closing idle HTTP connections on exit. The implementation is clean, follows Go best practices with proper defer usage, and applies the fix consistently across all 5 command entry points.
Suggestions (non-blocking):
- Consider using English comments for broader maintainability, though this is consistent with existing codebase style.
No critical issues or warnings found. The fix is ready to merge.
🤖 AI Code Review
SummaryThis PR addresses a CLI hang issue where the process doesn't exit after command completion due to GitLab SDK's underlying Review Statistics
Critical Issues
None Warnings
None Suggestions
Positive Feedback
ℹ️ About this reviewThis review was automatically generated using the
|
Summary
go-retryablehttp维持的 idle HTTP connections 未被关闭GitLabClient.CloseIdleConnections()方法,在所有命令函数中通过defer调用确保退出时立即释放连接Changes
pkg/client/client.go: 新增CloseIdleConnections()方法internal/cli/cmd.go: 所有 5 个run*函数添加defer gitlabClient.CloseIdleConnections()Test plan
gitlab-cli user delete --username <user>验证命令完成后立即退出gitlab-cli user list --prefix <prefix>验证同样秒退make test通过🤖 Generated with Claude Code