Repository navigation
Description
jcode server reload fails immediately with:
Error: server reload failed: Client must Subscribe with a working_dir before sending stateful requests
This is not environment-specific — the command appears to be broken for every invocation, on a stock release binary.
Reproduction
$ jcode --version
jcode v0.61.0 (c5009da0)
$ jcode server reload
Error: server reload failed: Client must Subscribe with a working_dir before sending stateful requestsAny running server reproduces it. --force fails the same way.
Expected vs actual
- Expected: the daemon reloads (or reports it is already current).
- Actual: the command always errors before the server processes the reload.
Cause
run_server_reload_command in src/cli/commands.rs connects and then sends the
stateful Reload request without subscribing first:
let mut client = crate::server::Client::connect().await?;
// ... repair_stale_shared_server_channel() ...
client.reload_with_force(force).await?;The server requires a Subscribe as the first frame. In
crates/jcode-app-core/src/server/client_lifecycle.rs,
initial_subscribe_working_dir rejects any other opening request with exactly
this message.
So the first frame on the wire is reload, and the server rejects it.
Possible fix
Subscribing before the reload request is enough. Client::subscribe() already
defaults working_dir to the current directory, which satisfies the server's
absolute-path requirement:
let mut client = crate::server::Client::connect().await?;
client.subscribe().await?;Notes for testing
Two things that are easy to trip over when writing a regression test:
jcode server reloadopens a throwaway liveness-probe connection first
(has_live_listener) and closes it without sending data, so a stub server has
to keep accepting until a connection actually delivers a frame.- The wire tag is lowercase
subscribe/reload, per the#[serde(rename)]
attributes onRequestincrates/jcode-protocol/src/wire.rs.
Pointing the binary at a stub socket via JCODE_SOCKET and asserting the first
frame is subscribe reproduces the bug directly: with the current code the first
frame is reload.
I have this change plus a test running locally in a fork if a reference is
useful, but per CONTRIBUTING I'm filing this as an issue rather than a PR since
it reproduces trivially.
Activity
docs: record upstream's issues-over-PRs policy
1jehuang commentedon Jul 29, 2026
Confirmed.
run_server_reload_commandconnected and sent the statefulReloadframe directly, and the server requiresSubscribeas its opening frame, so the command could never succeed.Fixed in #656 by calling
client.subscribe().await?before the reload request, exactly as you suggested, sincesubscribe()already defaultsworking_dirto the current directory.Thanks also for the two testing notes: the throwaway liveness probe from
has_live_listenerand the lowercasesubscribe/reloadwire tags are both easy traps, and they saved real time. I have not added the stub-socket regression test yet; the fix is verified by compilation and the code path, and the test wants a bit of harness scaffolding to do properly. Flagged in the PR for review.--- — Jcode agent (automated triage), on behalf of @1jehuang
1jehuang commentedon Jul 29, 2026
Follow-up: verified end-to-end against a running daemon, rather than only by inspection as I said earlier.
I ran the built binary against an isolated daemon (private
JCODE_SOCKET,JCODE_HOME, andXDG_RUNTIME_DIRso it could not touch a real session), then mutation-checked it by reverting just thesubscribe()call and rebuilding:Without the fix:
With the fix:
That is your reported error reproduced exactly and then resolved, so the fix is confirmed rather than assumed.
One note on writing a permanent regression test, since you raised it: the naive version passes vacuously. If the harness does not wait for the daemon to actually signal ready,
server reloadtakes thehas_live_listenerearly return and prints "No running jcode server found", exiting 0 without ever exercising the reload path. My first attempt did exactly that and looked green. Any committed test needs to assert it did not hit that branch.--- — Jcode agent (automated triage), on behalf of @1jehuang
fix: five triage fixes for Gemini schemas, macOS stdin, reload, MCP m…
fix: five triage fixes for Gemini schemas, macOS stdin, reload, MCP m…
fix: five triage fixes for Gemini schemas, macOS stdin, reload, MCP m…
fix: five triage fixes for Gemini schemas, macOS stdin, reload, MCP m…
fix: five triage fixes for Gemini schemas, macOS stdin, reload, MCP m…
fix: five triage fixes for Gemini schemas, macOS stdin, reload, MCP m…
fix: five triage fixes for Gemini schemas, macOS stdin, reload, MCP m…