Repository navigation
fix: release lock guards before awaiting channel send (#869) - #1003
Conversation
Clone `mpsc::Sender` out of `RwLock` before `.send().await` to prevent read guards from blocking write lock acquisition (shutdown/start) when the channel buffer is full. Fixed call sites: - src/channels/http.rs: process_message() - src/channels/web/server.rs: chat_send_handler(), chat_approval_handler() - src/channels/web/handlers/chat.rs: chat_send_handler(), chat_approval_handler() - src/channels/web/ws.rs: handle_client_message() (2 sites) - src/channels/wasm/wrapper.rs: process_emitted_messages() (2 impls, also scoped rate_limiter write lock per-iteration) Includes regression test: shutdown_completes_while_process_message_blocked Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 84802e1)
The regression-test-check workflow failed because origin/main wasn't available as a ref in the CI environment. actions/checkout@v4 fetches the PR merge ref history but doesn't make the base branch ref available for three-dot diff comparisons. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 1d5a7bd)
(cherry picked from commit 784d444)
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request cherry-picks critical fixes from a previous PR (#905) to resolve a deadlock issue in asynchronous channel operations. The core problem involved Highlights
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Staging replacement for #905. This PR cherry-picks the actual lock-guard fix plus the regression-check workflow fix onto current |
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a potential deadlock issue by ensuring RwLock read guards are not held across .await points. The fix is consistently applied across multiple channel implementations (http, wasm, web). Cloning the mpsc::Sender and scoping lock acquisitions are idiomatic and effective solutions in async Rust. The inclusion of a regression test in src/channels/http.rs is particularly commendable, as it specifically targets the deadlock scenario and ensures the fix is robust. The changes are clean, well-commented, and significantly improve the concurrency safety of the channel implementations.
…earai#1003) * fix: release lock guards before awaiting channel send (nearai#869) Clone `mpsc::Sender` out of `RwLock` before `.send().await` to prevent read guards from blocking write lock acquisition (shutdown/start) when the channel buffer is full. Fixed call sites: - src/channels/http.rs: process_message() - src/channels/web/server.rs: chat_send_handler(), chat_approval_handler() - src/channels/web/handlers/chat.rs: chat_send_handler(), chat_approval_handler() - src/channels/web/ws.rs: handle_client_message() (2 sites) - src/channels/wasm/wrapper.rs: process_emitted_messages() (2 impls, also scoped rate_limiter write lock per-iteration) Includes regression test: shutdown_completes_while_process_message_blocked Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 84802e1) * ci: fetch base branch before regression test check The regression-test-check workflow failed because origin/main wasn't available as a ref in the CI environment. actions/checkout@v4 fetches the PR merge ref history but doesn't make the base branch ref available for three-dot diff comparisons. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 1d5a7bd) * chore(ci): rerun regression gate [skip-regression-check] (cherry picked from commit 784d444) --------- Co-authored-by: Umesh Kumar Singh <brijbiharisingh1971@outlook.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…earai#1003) * fix: release lock guards before awaiting channel send (nearai#869) Clone `mpsc::Sender` out of `RwLock` before `.send().await` to prevent read guards from blocking write lock acquisition (shutdown/start) when the channel buffer is full. Fixed call sites: - src/channels/http.rs: process_message() - src/channels/web/server.rs: chat_send_handler(), chat_approval_handler() - src/channels/web/handlers/chat.rs: chat_send_handler(), chat_approval_handler() - src/channels/web/ws.rs: handle_client_message() (2 sites) - src/channels/wasm/wrapper.rs: process_emitted_messages() (2 impls, also scoped rate_limiter write lock per-iteration) Includes regression test: shutdown_completes_while_process_message_blocked Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 84802e1) * ci: fetch base branch before regression test check The regression-test-check workflow failed because origin/main wasn't available as a ref in the CI environment. actions/checkout@v4 fetches the PR merge ref history but doesn't make the base branch ref available for three-dot diff comparisons. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 1d5a7bd) * chore(ci): rerun regression gate [skip-regression-check] (cherry picked from commit 784d444) --------- Co-authored-by: Umesh Kumar Singh <brijbiharisingh1971@outlook.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Supersedes #905 for the staging merge train.