-
Notifications
You must be signed in to change notification settings - Fork 276
Closed
Labels
automatedIssues created by cagentIssues created by cagentkind/bugSomething isn't workingSomething isn't working
Description
🟠 high - bug
File: cmd/root/mcp.go (line 48)
Code
ln, err := listenAndCloseOnCancel(ctx, f.listenAddr)
if err != nil {
return err
}
return mcp.StartHTTPServer(ctx, agentFilename, f.agentName, &f.runConfig, ln)Problem
The ln listener is created by listenAndCloseOnCancel and passed to mcp.StartHTTPServer. While listenAndCloseOnCancel spawns a goroutine to close the listener when the context is cancelled, if mcp.StartHTTPServer returns an error before the context is cancelled, or if it doesn't explicitly close the listener, the listener may remain open, causing a resource leak.
Suggested Fix
Add a defer ln.Close() right after the listener is successfully created to ensure it's always closed when the function exits, regardless of how mcp.StartHTTPServer exits.
Found by nightly codebase scan
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
automatedIssues created by cagentIssues created by cagentkind/bugSomething isn't workingSomething isn't working