chenhg5/cc-connect · error

runtime config stdout pipe: %w

Error message

runtime config stdout pipe: %w

What it means

loadCodexRuntimeConfig failed while creating the child process's stdout pipe via cmd.StdoutPipe() before starting the codex app-server probe process. Like the stdin-pipe variant, this indicates the OS refused to allocate a pipe — typically resource exhaustion — and runtime configuration cannot be retrieved.

Source

Thrown at agent/codex/session.go:673

	}
	return s == "completed" || s == "success" || s == "succeeded" || s == "ok"
}

func loadCodexRuntimeConfig(ctx context.Context, workDir string, extraEnv []string) (string, string, error) {
	cmd := exec.CommandContext(ctx, "codex", "app-server")
	cmd.Dir = workDir
	prepareCmdForKill(cmd)
	if len(extraEnv) > 0 {
		cmd.Env = core.MergeEnv(os.Environ(), extraEnv)
	}

	stdin, err := cmd.StdinPipe()
	if err != nil {
		return "", "", fmt.Errorf("runtime config stdin pipe: %w", err)
	}
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return "", "", fmt.Errorf("runtime config stdout pipe: %w", err)
	}
	var stderr bytes.Buffer
	cmd.Stderr = &stderr

	if err := cmd.Start(); err != nil {
		return "", "", fmt.Errorf("runtime config start app-server: %w", err)
	}
	defer func() {
		_ = stdin.Close()
		if cmd.Process != nil {
			_ = cmd.Process.Kill()
		}
		_ = cmd.Wait()
	}()

	reader := bufio.NewReader(stdout)
	nextID := int64(1)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Check and raise the file-descriptor limit (`ulimit -n`) for the cc-connect daemon.
  2. Kill leaked codex app-server processes and verify sessions are stopped so pipes get released.
  3. Retry after freeing descriptors; this error is not caused by the codex binary itself.
  4. Reduce concurrent agent sessions if the process is creating many child processes at once.

Example fix

// before: systemd unit with default LimitNOFILE=1024 under heavy session load
// after: cc-connect.service
[Service]
LimitNOFILE=65536
Defensive patterns

Strategy: retry

Validate before calling

var lim syscall.Rlimit
syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)
if lim.Cur < 4096 {
    return fmt.Errorf("insufficient fd headroom: %d", lim.Cur)
}

Try / catch

cfg, _, err := loadCodexRuntimeConfig(ctx, ...)
if err != nil && strings.Contains(err.Error(), "stdout pipe") {
    time.Sleep(500 * time.Millisecond)
    cfg, _, err = loadCodexRuntimeConfig(ctx, ...)
}

Prevention

When it happens

Trigger: cmd.StdoutPipe() returns a non-nil error inside loadCodexRuntimeConfig after the stdin pipe was created successfully.

Common situations: File-descriptor exhaustion from leaked child processes or concurrent sessions; sandboxed/containerized environments with tight RLIMIT_NOFILE; fork/exec resource limits on shared hosts.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/87e0000a87726ef9. Report an issue: GitHub.