fix(rust): leaking connections, clippy and tests + examples#1
fix(rust): leaking connections, clippy and tests + examples#1
Conversation
WalkthroughMultiple example files updated import paths from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@rust/examples/stream_write_example.rs`:
- Around line 75-77: The spawned writer task currently takes ownership of
StreamHandle (variable handle) and drops it when the task exits, which sends a
close signal and can terminate streaming early; fix by keeping the original
handle in the main scope and instead clone an Arc (or the handle's cloneable
wrapper) into the writer task so the task uses a cloned handle while the main
retains ownership — locate usages of handle in the writer spawn (where
transaction_request is written) and change to clone the shared handle for the
task, ensuring the main scope's handle is not moved/dropped when the task
finishes (also apply the same change for the other writer block around the
second occurrence).
In `@rust/test/subscription_replacement_persistence.rs`:
- Around line 127-134: The writer task currently owns and drops the StreamHandle
(`handle`) after write(), which triggers its Drop and can prematurely close the
stream; instead keep the live handle in the main task and share it with the
spawned writer using a thread-safe reference (e.g., wrap the StreamHandle in an
Arc and clone that Arc into the writer task or use Arc<Mutex<...>> if mutation
is required) so the original Arc in main remains until post-write reconnect
validation completes; update references to `handle` in the spawned task to use
the cloned Arc and ensure the main retains ownership of the original Arc until
validation finishes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: c8c1a9ed-868d-48d5-8408-80695b6bc8c0
⛔ Files ignored due to path filters (1)
javascript/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (20)
rust/examples/account_sub.rsrust/examples/accounts_data_slice_sub.rsrust/examples/basic_usage.rsrust/examples/block_meta_sub.rsrust/examples/block_sub.rsrust/examples/channel-options-example.rsrust/examples/compression-advanced.rsrust/examples/compression-example.rsrust/examples/entry_sub.rsrust/examples/preprocessed_transaction_sub.rsrust/examples/slot_sub.rsrust/examples/stream_write_example.rsrust/examples/transaction_status_sub.rsrust/examples/transaction_sub.rsrust/examples/verify_no_internal_filters.rsrust/src/client.rsrust/test/account_integrity.rsrust/test/block_integrity.rsrust/test/subscription_replacement_persistence.rsrust/test/transaction_integrity.rs
Summary
Fix connection leak caused by
StreamHandlenot signaling the background stream to shut down when dropped. Also fix broken imports and clippy warnings across all Rust examples and tests.Details
rust/src/client.rs
StreamHandleno longer derivesClone. It now owns awatch::Sender<bool>that signals the background async stream to terminate when the handle is dropped.Dropimpl that sendstrueon the close channel.close_rx.changed()insidetokio::select!— both during active streaming and during the 5-second reconnect delay — so shutdown is immediate regardless of state.Examples & Tests
account_sub,accounts_data_slice_sub,block_meta_sub,block_sub,entry_sub,slot_sub,transaction_sub,transaction_status_sub) had broken imports referencing a nonexistentyellowstone_grpc_protocrate; replaced withhelius_laserstream::grpcre-exports.stream_write_example.rsandsubscription_replacement_persistence.rs: removedhandle.clone()usage sinceStreamHandleis no longerClone; moved handle directly into spawned tasks.compression-advanced.rs: refactored field reassignment into struct literal initialization to satisfy clippy.block_integrity.rs: removed redundant..Default::default()on exhaustive struct.transaction_integrity.rs: extractedStatusMaptype alias to fixtype_complexitywarning.uninlined_format_argsclippy fixes across examples and tests.Summary by CodeRabbit
New Features
Refactor