Skip to content

Simplify watcher run_tasks shutdown flow#760

Closed
ok300 wants to merge 4 commits intopubky:fix/task-panicfrom
ok300:copilot/investigate-nexuswatcher-avoid-spawn-loop
Closed

Simplify watcher run_tasks shutdown flow#760
ok300 wants to merge 4 commits intopubky:fix/task-panicfrom
ok300:copilot/investigate-nexuswatcher-avoid-spawn-loop

Conversation

@ok300
Copy link
Contributor

@ok300 ok300 commented Mar 4, 2026

This PR attempts to simplify #757 by removing the need to use spawn_processing_loop.

Copilot AI and others added 2 commits March 4, 2026 21:44
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>

Inline watcher loops and add panic non-hang tests

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>

test: consolidate panicking runners in missed_tick_skip tests

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>

test: consolidate panicking service test runners

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>

test: merge duplicate panicking runners in watcher tests

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
@ok300 ok300 marked this pull request as ready for review March 4, 2026 21:01
@ok300 ok300 requested a review from tipogi March 4, 2026 21:01
@ok300 ok300 force-pushed the copilot/investigate-nexuswatcher-avoid-spawn-loop branch from 3a0b240 to 7589c2b Compare March 5, 2026 05:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Simplifies the watcher task shutdown/error-handling flow by inlining the processing loops in NexusWatcher::run_tasks (removing the spawn_processing_loop helper) and updating test utilities to exercise panic paths with a single configurable runner.

Changes:

  • Inline the default/external homeserver processing loops directly in NexusWatcher::run_tasks and remove spawn_processing_loop.
  • Replace separate panicking runner test helpers with a single PanickingRunner + PanicTarget, and add a timeout-based non-hanging assertion test.
  • Update existing shutdown-guard tests and utility exports to use the new runner.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
nexus-watcher/src/service/mod.rs Refactors run_tasks to spawn two explicit loops and removes the helper function.
nexus-watcher/tests/service/utils/panicking_runner.rs Introduces PanicTarget/PanickingRunner and adds a timeout-based test to ensure panics don’t hang run_tasks.
nexus-watcher/tests/service/utils/mod.rs Updates re-exports to the new panicking runner types.
nexus-watcher/tests/service/shutdown_guard.rs Updates tests to use PanickingRunner and adjusts test documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -85,53 +84,67 @@ impl NexusWatcher {
/// Three parallel tasks are spawned:
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The run_tasks doc comment says "Three parallel tasks are spawned", but the implementation now spawns only two tasks (default + external) and the shutdown-forwarder task has been removed. Update the comment to match the current behavior so callers/test readers aren’t misled.

Suggested change
/// Three parallel tasks are spawned:
/// Two parallel tasks are spawned:

Copilot uses AI. Check for mistakes.
}
/// Ensures `run_tasks` returns promptly with `Err` if a HS-processing task panics.
#[tokio_shared_rt::test(shared)]
async fn test_panicking_external_task_does_not_hang_run_tasks() -> Result<()> {
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test name implies only the external task panic case, but the body also asserts the default-homeserver panic path. Rename the test (or split into two tests) so the name matches what’s being verified.

Suggested change
async fn test_panicking_external_task_does_not_hang_run_tasks() -> Result<()> {
async fn test_panicking_tasks_do_not_hang_run_tasks() -> Result<()> {

Copilot uses AI. Check for mistakes.
@ok300
Copy link
Contributor Author

ok300 commented Mar 5, 2026

Superseded by #761

@ok300 ok300 closed this Mar 5, 2026
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.

3 participants