Repository navigation
fix(daemon-client): report a newer daemon that won a startup race as daemon-incompatible - #4801
Conversation
…daemon-incompatible `ensureDaemon` judges a daemon it observes directly and reports a newer one with `details.reason: 'daemon-incompatible'`. In a startup race it reported the same condition with no typed reason: the launch lost the registration lock, `observeContendingDaemon` read the winner through `readReusableLocalDaemon`, and that threw the newer-daemon refusal before it consulted `retireIncompatibleContender`. `start` catches only `daemon-contended`, so the caller received an error with no `details.reason` and branched wrong. A client that may not retire contenders now reports the race for any winner, so `ensureDaemon` judges it again and answers with the reason it owns. The managed route keeps its refusal and its wording. Co-Authored-By: Callstack Apex <noreply@callstack.com>
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
|
The fix at 4a05c1b reads correctly, and CI is green (19 checks, none failing), and there are no conflicts. One small duplication in the new test should go before merge. The new startup-race test re-declares two helpers that already exist in Not blocking, and you can take or leave these: |
* origin/main: feat(gesture): hold before the move with gesture pan --hold-ms (#4767) docs: clarify device verification and security proposals (#4805) fix(daemon-client): say that a hung daemon is stopped before ensureDaemon starts a new one (#4803) test: remove five timing races from CI (#4800) refactor(remote): save a remote script from memory with the local publisher (#4802) refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (#4774) fix(android): require acknowledgements for test IME typing (#4722) feat(scroll): add scroll refresh for pull-to-refresh (#4770) refactor(host-kit): add request Scope and use it for the wait capture deadline (#4794) fix(android): let permission all change nothing on an app that declares no permissions (#4796) fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (#4797) fix(host-kit): accept a group-writable script directory the user owns (#4799)
…eason and share the test helpers Review follow-up: failureOf and identityIn move to the lifecycle fixture, the race test is named for the decision it covers, and the managed route's refusal of a newer daemon now carries daemon-incompatible / newer as well. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Addressed in 7695b8d (main merged in).
Production is now +7 −4, net +3 lines against main. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 7695b8d. The verdict and the full list are in the summary comment.
…n the managed newer-daemon refusal Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
This PR is ready at 29f871e. |
* origin/main: refactor(apple-runner): generate the Swift runner error-code enums from runner-contract.ts (#4810) fix(daemon-client): report a newer daemon that won a startup race as daemon-incompatible (#4801) feat(shake): add a shake command for iOS simulators and Android emulators (#4741) fix(daemon): give a closing daemon its full teardown before anything kills it (#4806) fix(android): use typed evidence in the readiness boot poller (#4717)
Summary
ensureDaemonreports a daemon newer than the client withdetails.reason: 'daemon-incompatible'anddetails.mismatch: 'newer', so callers can branch on the reason. When it lost a startup race to that newer daemon, it reported the same condition with no typed reason:startcatches onlydaemon-contended, and the refusal that reached the caller had none, so an SDK caller branched wrong.readReusableLocalDaemonthrewnewerDaemonRefusedErrorbefore consultingsettings.retireIncompatibleContender, so a client that may not retire contenders got that untyped refusal fromobserveContendingDaemon. The fix moves that check above therefuseNewerthrow: such a client reports the race,ensureDaemonjudges the winner again, and the canonicaldaemon-incompatibleerror answers. Two files, no new wire reason literal.What each caller of
readReusableLocalDaemonsees:observeContendingDaemon→ensureDaemon.start(retireIncompatibleContender: false, the only route where it is false): a newer winner now reaches the existingdaemon-contendedbranch, so the nextensureOncejudges it and throwsdaemon-incompatible/mismatch: 'newer'. Every other non-reusewinner behaved this way already.ensureLocalDaemon(retireIncompatibleContender: true; CLI, MCP, proxy upstream, SDK managed client): unchanged — keepsnewerDaemonRefusedErrorand its wording, so the existing newer-daemon tests pass unchanged.Part of #4649.
Validation
Base
74771e1919, head4a05c1b3f7.daemon-client-ensure-startup-race.test.ts(real launch plus a real newer child that wins the lock).pnpm exec vitest run --project unit-core packages/daemon-client/src/__tests__/daemon-client-ensure-startup-race.test.ts: base → fails,details.reasonundefined; head → passes. Gross +140/-3; production net 0 (3/3, reordering only) against the ≤ +3 budget.packages/daemon-client(348 tests) andpackages/daemon-contracts(240) pass; the daemon-fixture-launch and mutation-scope guards pass.pnpm build,pnpm typecheck,pnpm lint,pnpm formatand the layering check (R84, R89 quiet) pass. CI owns full validation; no new allowlist, baseline or budget row.🤖 Generated with OpenCode (Callstack Apex)
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.