Skip to content

Fix ZMQ socket file descriptor leak in agent heartbeat and IPC#22

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/fix-ckdtr-heartbeat-error
Closed

Fix ZMQ socket file descriptor leak in agent heartbeat and IPC#22
Copilot wants to merge 4 commits intomainfrom
copilot/fix-ckdtr-heartbeat-error

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 14, 2026

Agent fails after 3-4 minutes with EMFILE: No file descriptors available (os error 24). Root cause: ReqSocket instances created for each API call (heartbeats every 5s, status updates) were never explicitly closed, relying only on Drop trait which doesn't guarantee immediate FD release.

Changes

zmq_helpers.rs: Explicit socket cleanup in request-reply cycle

let result = match req.send(zmq_msg).await {
    // ... handle send/recv ...
};
// Explicitly close socket to release file descriptors
let close_errors = req.close().await;
if !close_errors.is_empty() {
    warn!("Errors closing ZMQ request socket for {}: {:?}", tcp_uri, close_errors);
}
result

log_manager/publisher.rs: Close old socket before reconnect

  • Use std::mem::replace to extract old socket before creating new one
  • Call .close() explicitly to prevent FD accumulation during reconnects

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 14, 2026 15:23
Co-authored-by: nicelgueta <30913420+nicelgueta@users.noreply.github.com>
Co-authored-by: nicelgueta <30913420+nicelgueta@users.noreply.github.com>
Co-authored-by: nicelgueta <30913420+nicelgueta@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix heartbeat sending failure on small machines Fix ZMQ socket file descriptor leak in agent heartbeat and IPC Feb 14, 2026
Copilot AI requested a review from nicelgueta February 14, 2026 15:39
@nicelgueta nicelgueta closed this Feb 17, 2026
@nicelgueta nicelgueta deleted the copilot/fix-ckdtr-heartbeat-error branch February 17, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants