fix(zerocode): detect daemon version mismatches#8192
Conversation
singlerider
left a comment
There was a problem hiding this comment.
I traced both connect paths, the main-loop fallback behavior, and the i18n wiring.
🟢 What looks good: the version mismatch no longer triggers a spurious daemon spawn
The real bug here is that a local-socket connect failure fell straight through to spawn_ephemeral_daemon, so a version-mismatched daemon would get masked by a fresh spawn or a silent retry. Now connect returns a typed DaemonVersionMismatch, and both main's fallback arm and the await_daemon_ready retry loop short-circuit with Err(e) if is_daemon_version_mismatch(&e). The user sees the actionable rebuild message instead of confusing spawn churn. That is the right place to cut the fallback.
🟢 What looks good: read_task is aborted on every failure path
The old code used ? after the initialize request, which would drop out without aborting the spawned read_task. The refactor replaces both the request and the parse with explicit match arms that call read_task.abort() before returning, on both the local and remote connect paths, symmetrically. That closes the task-leak on a failed handshake.
🟢 What looks good: the typed error round-trips cleanly
DaemonVersionMismatch carries the static client version from env!("CARGO_PKG_VERSION") and the server-reported string, and format_startup_error downcasts it to render the localized zc-error-daemon-version-mismatch with both versions interpolated. The error stays typed all the way to the top instead of being flattened into a string early.
🟢 What looks good: locale parity and interpolation are tested
All five locales (en, es, fr, ja, zh-CN) carry the new key, and the i18n test asserts both client_version and server_version placeholders actually interpolate. That guards against a locale that silently drops an argument.
CI green, no outstanding reviews.
Summary
masterserver_versionreturned byinitializein zerocode local and WSS RPC clients, so mismatched or missing versions fail during connect instead of surfacing later as generic RPC timeouts.zerocodeRPC connect/startup paths for local IPC and WSS, plus zerocode locale catalogs for the new startup error.bug,risk: medium,size: S,zerocodeValidation Evidence (required)
zc-cargo fmt -p zerocode— passed.zc-cargo test -p zerocode— passed:115 passedinsrc/lib.rs;360 passedinsrc/main.rs; doc-tests ran with0tests.git diff --check— passed.initialize.server_version.Security & Privacy Impact (required)
NoNoNoNoYes, describe the risk and mitigation:N/ACompatibility (required)
YesNoNoorYesto either: Matching zerocode/daemon builds behave as before. If users see the new mismatch error, rebuild and restart the daemon from the same checkout as zerocode.Rollback (required for
risk: mediumandrisk: high)git revert <merge-commit>zerocodeexits at startup with the version-mismatch message, or fails to connect to a daemon that previously connected.