fix(rpc): publish close after registry removal and join watcher shutdown - #1702
Merged
Merged
Conversation
Close acknowledgements and session_closed, including worker-failure terminals, wait for the session registry to drop the handle. closeMarked still returns at the close-grace deadline so a worker stuck in a syscall cannot wedge cancel. Watcher registration checks cancellation before and after fs.watch; close() joins disposers; reentrant RPC shutdown shares that join and keeps a failure exit code; nonpersistent RPC probes start no watchers. Plan: .omo/plans/omo-dependency-diet.md
code-yeongyu
force-pushed
the
fix/rpc-close-ordering-and-watcher-shutdown
branch
from
September 15, 2026 09:10
7993fca to
08bffe7
Compare
The admitted interleaving posts unwatch during fs.watch. Delivering that unwatch in the same IPC drain hid a missing post-watch close. Snapshot the queued commands so only the watch message runs. Plan: .omo/plans/omo-dependency-diet.md
finalizeClose waits on registry.peek().closeCompletion. The joined-close fakes omitted peek, so close_session threw TypeError before publishing. Plan: .omo/plans/omo-dependency-diet.md
code-yeongyu
deleted the
fix/rpc-close-ordering-and-watcher-shutdown
branch
September 15, 2026 11:34
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RPC session close and config-watcher shutdown now observe ownership barriers on every path, including the interleavings that the previous patch-shaped port missed.
close_sessionacknowledgements andsession_closedevents are published only after the session registry has removed the entry. Worker-failure terminals use the same barrier, so an immediatelist_sessionsnever returns the closed session.fs.watch. A shutdown that wins the post-load/pre-registration gap closes the native handle instead of retaining it.ConfigReloadWatchEngine.close()cancels synchronously and joins returned disposers; repeated close shares that join.shutdown()joins in-flight disposal and keeps a failure exit code (serializer-error overlapping stdin EOF).Why
An immediate
list_sessionsafter close must not observe the closed handle, including when the worker fails instead of a clean close. Fire-and-forget watcher unsubscribe during process exit left native streams running into teardown. Snapshot-only RPC probes never needed live watches.Tests
Seam-driven regressions cover successful close vs grace deadline, worker error/failure frames, queued vs admitted watcher cancellation, reentrant shutdown join, and persistent vs nonpersistent RPC probe watching. Related watch-message assertions now allow the cancellation token field.
Coordination
Does not edit
host-lifecycle.tsorhost-ensure.ts. Open PR #1662 also editsCHANGELOG.mdandpackages/coding-agent/src/modes/rpc/changes.md; those changelog hunks may need a combine on merge.Refs #1656
Plan: .omo/plans/omo-dependency-diet.md
Summary by cubic
Fixes RPC session close ordering and watcher shutdown so an immediate
list_sessionsafter close never returns the closed session and native watchers do not outlive teardown.close_sessionacknowledgements andsession_closedevents now wait for the session registry to remove the entry, including worker-failure terminals;closeMarkedstill returns at the grace deadline so a stuck worker cannot hang cancel/close.fs.watch;close()cancels synchronously and joins all disposers, and repeated close shares that join.shutdown()joins in-flight disposal and preserves a non-zero exit code.Refs #1656
Written for commit dcc0dd2. Summary will update on new commits.