Repository navigation
fix(process-daemon): block subscriptions instead of polling - #59698
Merged
Merged
Conversation
This was referenced Oct 27, 2026
jlongster
force-pushed
the
process-daemon-import
branch
from
October 27, 2026 19:54
58833a6 to
985f7a3
Compare
jlongster
force-pushed
the
daemon-subscription-poll
branch
from
October 27, 2026 19:55
3a2ce2d to
a51d51c
Compare
jlongster
force-pushed
the
daemon-subscription-poll
branch
from
October 27, 2026 20:07
a51d51c to
d00c1a5
Compare
alsuren
pushed a commit
to alsuren/opencode
that referenced
this pull request
Oct 28, 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.
Ported from anomalyco/opencode-pty#28. Builds on #59694 (
process-daemon-import, merged).Issue for this PR
Related to anomalyco/opencode-pty#25
Type of change
What does this PR do?
daemon-handler-spawn→daemon-control→daemon-poll-loop→daemon-windows-poll.stream_subscription(packages/process-daemon/src/daemon/server.rs) waited incrossbeam_channel::select!with adefault(Duration::from_millis(100)) => continuearm. That arm did nothing useful: it only looped back to check the shutdown flag again, so every attached subscription woke about 10 times a second while the terminal was idle. Remove it, so the handler now blocks until the disconnect monitor fires or a stream event arrives. The shutdown check at the top of the loop stays.runcancels every handler connection before joining:Cancellation::cancelcallsshutdown(Both)on the socket. TheDisconnectMonitorread then returns,disconnected()becomes ready, and the select exits.Pipe::cancelsets the manual-reset cancelled event.Operation::waitwaits on that event, so the monitor's pending read fails, and so does any new operation (Operation::newchecks it first).service.shutdown()stops every terminal actor, which drops the subscription event senders, sorecv(attachment.events)ends withErrand the loop breaks.The commit applied to the monorepo unchanged (identical patch ID to the opencode-pty commit).
How did you verify your code works?
packages/process-daemon/tests/ownership.rs::shutdown_ends_an_idle_subscription: attaches an observer to an idleexec catterminal, shuts down through the owner, and checks that the subscription stream reaches EOF within the client's 3s read timeout and that the daemon exits cleanly. On the original PR it ran 5 times in a row; all passed in about 0.08s each.packages/process-daemon):cargo fmt --check,cargo clippy --locked --all-targets --all-features -- -D warnings, andcargo test --locked --lib(40 passed) pass.daemon-windows-poll) the full macOS CI test selection and Windows/Linux cross clippy also pass.cargo test --locked --lib --test service --test runtime --test ownership --test rows --test ghostty-effects(lib 40, ghostty-effects 5, ownership 8, rows 1, runtime 8 + 1 ignored, service 9).Screenshots / recordings
N/A, internal daemon change.
Checklist