Skip to content

Make npackd handle connections concurrently - #9

Merged
imattau merged 1 commit into
masterfrom
phase2-concurrent-daemon-and-progress
Sep 21, 2026
Merged

imattau merged 1 commit into
masterfrom
phase2-concurrent-daemon-and-progress

Conversation

@imattau

@imattau imattau commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Makes the recursive dependency-install future Send (Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>) so npackd can tokio::spawn a task per accepted connection instead of handling them serially.
  • No behavior change to the install logic itself — this only relaxes the future's bound so it can cross the tokio::spawn boundary.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features (no warnings)
  • cargo test (47 passing, including a new daemon_serves_concurrent_connections test that runs the real run_daemon loop and issues two simultaneous ListInstalled calls over a real socket)
  • Manual smoke test: two simultaneous real GetPackage calls against npack's own live Nostr/Blossom release completed in ~11s total instead of ~20s sequential, with responses arriving out of order — confirming genuine concurrent handling, not just non-blocking accept

Not in this PR

GetTransaction/CancelTransaction and progress-event streaming remain future work (tracked in the roadmap). A safe CancelTransaction needs a real cooperative checkpoint in the install path (e.g. between packages in a dependency closure) rather than raw task abortion, which risks leaving the store half-installed — that's a larger, separate change.

🤖 Generated with Claude Code

Make the recursive dependency-install future Send (Pin<Box<dyn Future
+ Send + 'a>>) so each accepted npackd connection can be handled on
its own tokio::spawn task instead of serially. Verified with a real
concurrency test (two simultaneous ListInstalled calls against
run_daemon over a real socket) and manually against two simultaneous
real GetPackage network calls, which completed in ~11s total instead
of ~20s sequential.

GetTransaction/CancelTransaction and progress-event streaming remain
future work; a safe CancelTransaction needs a real cooperative
checkpoint in the install path rather than raw task abortion, which
risks leaving the store half-installed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@imattau
imattau merged commit 8df8989 into master Sep 21, 2026
3 checks passed
@imattau
imattau deleted the phase2-concurrent-daemon-and-progress branch September 21, 2026 01:11
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.

1 participant