Skip to content

fix(cli): make client_session_end idempotent on vanished daemon - #170

Merged
zackees merged 2 commits into
mainfrom
fix/client-session-end-idempotent
May 11, 2026
Merged

zackees merged 2 commits into
mainfrom
fix/client-session-end-idempotent

Conversation

@zackees

@zackees zackees commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Symptom

Windows Test has been red on PRs (incl. #169) despite every workspace test passing:

test result: ok. 148 passed; 0 failed; 10 ignored; …
…
"error": "cannot connect to daemon at \\.\pipe\zccache-…: I/O error: The system cannot find the file specified. (os error 2)",
soldr: zccache session-end 92ab0b0f-… failed: cannot connect to daemon at \.\pipe\zccache-…: I/O error: The system cannot find the file specified. (os error 2)
##[error]Process completed with exit code 1.

Source: https://github.com/zackees/zccache/actions/runs/25691489291/job/75428757112

The failure is teardown only — soldr's rust-plan save calls into the zccache library to end the session, and gets a hard error.

Root cause

client_session_end (crates/zccache-cli/src/lib.rs:775) is the in-process entry point used by:

  • crates/zccache-cli/src/python.rs:652 — the Python ZccacheClient.session_end binding (what soldr 0.7.14 uses via the cdylib)
  • direct Rust callers that link the zccache-cli rlib

It was the only session-end path that did not adopt the idempotency contract from #137 (daemon-side unknown UUID) / #151 (CLI subprocess connect failure) / #159 (shared library entry point session_end_idempotent). On connect-time NotFound (Windows: pipe gone), it formatted "cannot connect to daemon at {endpoint}: {e}" as a String error.

#163 switched cmd_session_end (the CLI subcommand) to session_end_idempotent, but library callers were left on the old, non-idempotent path. soldr is a library caller. Hence the failure.

Fix

Collapse client_session_end to a thin String-error wrapper around session_end_idempotent:

pub fn client_session_end(
    endpoint: Option<&str>,
    session_id: &str,
) -> Result<Option<zccache_protocol::SessionStats>, String> {
    let endpoint = resolve_endpoint(endpoint);
    session_end_idempotent(&endpoint, session_id).map_err(|e| e.to_string())
}

All callers — CLI, Python, soldr, future tools — now share one definition of "the daemon already died".

Regression test

client_session_end_swallows_vanished_daemon mirrors the existing session_end_idempotent_swallows_vanished_daemon: bind no listener, call with a fresh UUID, assert Ok(None).

Verification

  • soldr cargo test -p zccache-cli --lib — 4 / 4 relevant tests pass (new + 3 existing related)
  • soldr cargo clippy -p zccache-cli --all-targets -- -D warnings — clean

Test plan

  • CI Windows Test passes — no cannot connect to daemon teardown failure
  • Linux + macOS Test stays green
  • After merge: tag v1.4.1 to ship 1.4.1 with this fix included (the workspace is already at 1.4.1 from chore(release): bump workspace to 1.4.1 #169)

The Windows Test job has been failing PR teardown with

    soldr: zccache session-end <uuid> failed: cannot connect to daemon
    at \.\pipe\zccache-...: I/O error: The system cannot find the file
    specified. (os error 2)
    ##[error]Process completed with exit code 1.

even when every workspace test passed. Root cause: `client_session_end`
is the in-process entry point that soldr's `rust-plan save` and the
Python `ZccacheClient.session_end` binding call. It was the only
session-end path that did NOT yet adopt the idempotency contract from
#137 / #151 / #159 — connect-time `NotFound` on the named pipe was
returned as a hard `Err(String)` rather than `Ok(None)`. The CLI
subcommand was switched to `session_end_idempotent` in #163, but
library callers were left on the old, non-idempotent path.

Fix: collapse `client_session_end` to a thin String-error wrapper
around `session_end_idempotent`. All callers (CLI, Python, soldr,
future tools) now share one definition of "the daemon already died".

Regression test `client_session_end_swallows_vanished_daemon` mirrors
the existing `session_end_idempotent_swallows_vanished_daemon`: bind
no listener, call with a fresh UUID, assert `Ok(None)`.

Verification: `soldr cargo test -p zccache-cli --lib` — 4 / 4 relevant
tests pass; `soldr cargo clippy -p zccache-cli --all-targets -D warnings`
clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The Windows Test job has been failing every PR teardown with

    soldr: zccache session-end <uuid> failed: cannot connect to daemon
    at \.\pipe\zccache-...: I/O error: The system cannot find the file
    specified. (os error 2)
    ##[error]Process completed with exit code 1.

even after every workspace test passed. The bundled zccache 1.4.0
binary inside soldr 0.7.14 still uses the non-idempotent
`client_session_end` (fixed at the source level in the prior commit
on this branch). Source fix can't help in CI until soldr ships a new
release bundling zccache 1.4.1+, which is out of band.

Workflow-level workaround: after `cargo test`, if soldr exited non-zero,
check the captured output. If cargo itself reported no failed tests AND
the output contains exactly the soldr session-end teardown error, treat
the run as success and emit a GitHub workflow warning. Other non-zero
exits — real test failures, panics, build errors — still propagate
unchanged.

Targeted by:
  - "test result: FAILED" / "panicked at" must be absent (no real failure)
  - "soldr: zccache session-end .* failed: cannot connect to daemon"
    must be present (the specific teardown bug)

Once soldr's bundled zccache picks up the idempotent
`client_session_end`, this carve-out becomes dead code and can be
removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees

zackees commented May 11, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed a follow-up workflow workaround: be16278.

Why the first commit didn't fix CI

soldr 0.7.14 ships its own bundled zccache 1.4.0 (in ~/.soldr/bin/zccache-1.4.0/). That bundled binary is what soldr's at-exit rust-plan save actually invokes for session-end. The source-level fix in this PR only affects the workspace we build — it has no path to soldr's bundled binary until a future soldr release re-bundles zccache 1.4.1+.

What the new commit does

.github/workflows/ci-check.yml Test step now post-processes soldr's exit code. If soldr exited non-zero, but cargo itself reported no FAILED/panicked lines, and the captured output contains exactly the soldr teardown error pattern, we treat the run as success and emit a GitHub ::warning:: annotation. Anything else — a real test failure, a panic, a build error — still propagates unchanged.

This is a targeted, removable carve-out, not a blanket suppression. Once a soldr release ships zccache 1.4.1+, the carve-out becomes dead code (the underlying error stops happening) and can be deleted in one commit.

@zackees
zackees merged commit a23c96e into main May 11, 2026
25 checks passed
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.

1 participant