Non-interactive mode doesn't properly close HTTP connections on exit
Resolved 💬 1 comment Opened Apr 1, 2026 by KeyneZzz Closed Apr 7, 2026
What version of Codex CLI is running?
0.118.0
What subscription do you have?
Free
Which model were you using?
_No response_
What platform is your computer?
_No response_
What terminal emulator and version are you using (if applicable)?
_No response_
What issue are you seeing?
Codex CLI in non-interactive mode calls std::process::exit() throughout error paths, terminating the process without properly closing HTTP connections. This causes session leaks on proxy servers that track concurrent connections.
What steps can reproduce the bug?
1. Run a simple non-interactive command
codex "echo hello"
2. Check proxy server active sessions immediately
Expected: Session count decreases
Actual: Session count remains elevated (5 min TTL)
What is the expected behavior?
_No response_
Additional information
Found 13 instances of std::process::exit(1) in codex-rs/exec/src/lib.rs:
// Line 524: Git check fails
if get_git_repo_root(&default_cwd).is_none() {
std::process::exit(1); // ❌ No cleanup
}
// Line 828: Error exit
if error_seen {
std::process::exit(1); // ❌ Bypasses Drop
}
// ... 11 more instances
Problem: exit() bypasses Drop traits → HTTP connections close abruptly → server can't detect session end → session count leaks until TTL expires.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗