Skip to content

[p2p] stop background receiver when consumer channel closes#3308

Open
sashass1315 wants to merge 1 commit intocommonwarexyz:mainfrom
sashass1315:fix/p2p-background-receiver-consumer-shutdown
Open

[p2p] stop background receiver when consumer channel closes#3308
sashass1315 wants to merge 1 commit intocommonwarexyz:mainfrom
sashass1315:fix/p2p-background-receiver-consumer-shutdown

Conversation

@sashass1315
Copy link
Contributor

WrappedBackgroundReceiver previously ignored downstream closure and continued decoding/spawning work even after the consumer channel was dropped. This change makes decode handling return a continuation signal, exits the run loop when send_lossy indicates closure, and adds explicit closed-channel checks before scheduling new decode tasks. Added a regression test to ensure the background task exits promptly when the consumer is dropped.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Self::handle_decode_result(&mut self.blocker, &mut self.sender, result).await;
if !Self::handle_decode_result(&mut self.blocker, &mut self.sender, result).await {
break;
}
Copy link

Choose a reason for hiding this comment

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

While-loop break doesn't exit the run loop

Low Severity

When handle_decode_result returns false (consumer closed) inside the on_start while loop, the break only exits the while loop, not the outer loop generated by select_loop!. The post-while check on line 226 only tests saw_error and receiver_closed && decode_pool.is_empty() — it doesn't account for consumer closure. The consumer.closed() biased select branch catches this on the same iteration, so behavior is correct, but the gap is inconsistent with how saw_error propagates and could become a real bug if the select branches are reordered or the consumer.closed() fallback is removed.

Additional Locations (1)

Fix in Cursor Fix in Web

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