Skip to content

fix(worker): leave the event loop on a command channel error - #1914

Merged
FlorentinDUBOIS merged 2 commits into
mainfrom
fix/command-channel-error
Nov 3, 2026
Merged

FlorentinDUBOIS merged 2 commits into
mainfrom
fix/command-channel-error

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1912.

Problem

Server::run (lib/src/server.rs) returned on a hang-up of the command channel but only logged an error and continued. When the main process closes its end with a worker answer still unread, Linux resets the Unix stream, so the worker gets EPOLLERR rather than a plain hang-up. The channel is registered edge-triggered, so no further event arrives: the worker kept running with nothing left to drive it, and a caller joining its thread waited forever.

Change

An error on the command channel now makes the worker return, exactly like a close. The main process can no longer reach the worker in either case.

Protocol / security impact

None on the data plane. Command-channel lifecycle only: a worker whose main process is gone now exits instead of lingering.

Tests

  • New e2e worker_exits_when_command_channel_errors (e2e/src/tests/command_channel_security_tests.rs) reproduces the issue's steps: an answered Status, then an unread Status, a 300 ms wait, then drop the main end. It waits up to 5 s for the worker thread to finish.
    • Without the fix: worker still running 5 s after an error on its command channel (FAILED).
    • With the fix: ok.

Commands run

  • cargo +nightly fmt --all -- --check: exit 0
  • cargo clippy --all-targets --locked -- -D warnings: exit 0
  • cargo build --all-features --locked: exit 0
  • cargo test --workspace --locked -- --skip tests::fuzz_tests::: exit 0, 3415 passed, 0 failed (e2e: 669 passed)

Docs

CHANGELOG Unreleased › Fixed.

Dependencies

This branch also carries the lockfile-only commit of #1919 (pulldown-cmark 0.13.5 → 0.13.6 for RUSTSEC-2026-0433, and the yanked async-executor 1.14.0 → 1.14.1), so its cargo audit check passes on its own. The change is identical on every branch and merges cleanly in any order.

A worker treated an error on its command channel as a log line and went
on, while a hang-up made it return. The main process closing its end with
a worker answer still unread resets the Unix stream, so the worker sees
EPOLLERR rather than a plain hang-up; the channel is registered
edge-triggered, no further event arrives, and the worker ran forever with
nothing left to drive it, so a caller joining its thread hung.

Return from `Server::run` on an error exactly as on a close. The e2e test
reproduces the issue's steps (answered Status, unread Status, drop the
main end) and waits up to 5 s for the worker thread to finish.

Fixes #1912

Signed-off-by: Florentin Dubois <[email protected]>
`cargo audit --deny warnings` (CI "cargo audit") fails on main's
lockfile with two findings published after its last green run:

- RUSTSEC-2026-0433: pulldown-cmark 0.13.5, quadratic parsing of nested
  image wikilinks with ENABLE_WIKILINKS. Fixed in 0.13.6. A build
  dependency only, through prost-build.
- async-executor 1.14.0 is yanked. Moved to 1.14.1.

Lockfile-only: both are patch updates within the existing requirements.
Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 474bc09 into main Nov 3, 2026
46 checks passed
FlorentinDUBOIS added a commit that referenced this pull request Nov 3, 2026
Stacks this branch on #1916, #1918 and #1915, up to date with main after
#1919 (lockfile) and #1914, so CI runs on the tree this PR lands. Keeps
every CHANGELOG slot, each followed by a blank line.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS deleted the fix/command-channel-error branch November 4, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worker keeps running after an error on its command channel

2 participants