⚠️ Potential issue | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Inspect OnceTake API to confirm the best way to consume the channel.
rg -n "struct OnceTake|impl OnceTake|OnceTake<" -S --type=rust
Repository: gnosisguild/enclave
Length of output: 656
🏁 Script executed:
cat -n crates/utils/src/helpers.rs | sed -n '40,100p'
Repository: gnosisguild/enclave
Length of output: 916
🏁 Script executed:
cat -n crates/net/src/net_sync_manager.rs | sed -n '148,175p'
Repository: gnosisguild/enclave
Length of output: 1166
🏁 Script executed:
rg -n "self\.requests" crates/net/src/net_sync_manager.rs
Repository: gnosisguild/enclave
Length of output: 189
🏁 Script executed:
rg -n "requests\[|requests\.get|requests\.remove|requests\.insert" crates/net/src/net_sync_manager.rs
Repository: gnosisguild/enclave
Length of output: 189
🏁 Script executed:
cat -n crates/net/src/net_sync_manager.rs | sed -n '1,150p' | tail -50
Repository: gnosisguild/enclave
Length of output: 2090
🏁 Script executed:
rg -n "Handler.*SyncRequestReceived|Handler.*ReceiveEvents" crates/net/src/net_sync_manager.rs -A 2
Repository: gnosisguild/enclave
Length of output: 417
🏁 Script executed:
rg -n "impl Drop|impl.*Cleanup|requests\.clear\|fn drop" crates/net/src/net_sync_manager.rs
Repository: gnosisguild/enclave
Length of output: 45
🏁 Script executed:
rg -n "ReceiveEvents|struct ReceiveEvents" crates/net/src/ -B 2 -A 5
Repository: gnosisguild/enclave
Length of output: 1564
🏁 Script executed:
rg -n "struct ReceiveEvents" crates/net/src/ -A 10
Repository: gnosisguild/enclave
Length of output: 45
🏁 Script executed:
rg -n "ReceiveEvents" crates/ -A 5 | grep -A 5 "struct ReceiveEvents"
Repository: gnosisguild/enclave
Length of output: 364
🏁 Script executed:
cat -n crates/net/src/net_sync_manager.rs | sed -n '148,172p'
Repository: gnosisguild/enclave
Length of output: 1079
Remove fulfilled requests from requests to avoid unbounded growth.
Entries are never cleared after a response is sent, causing long-running nodes to accumulate stale entries indefinitely. Change .get() to .remove() to delete the entry from the HashMap once the response is sent. Since channel.to_owned() clones the OnceTake before removal, the sent channel remains functional.
Suggested change
- let Some(channel) = self.requests.get(&msg.id()) else {
+ let Some(channel) = self.requests.remove(&msg.id()) else {
bail!("request not found with {}", msg.id());
};
🤖 Prompt for AI Agents
In `@crates/net/src/net_sync_manager.rs` around lines 148 - 167, The handler for
ReceiveEvents in NetSyncManager currently uses self.requests.get(&msg.id()),
leaving entries in the requests map and causing unbounded growth; change the
lookup to remove the entry (use self.requests.remove(&msg.id())) so the request
is deleted once handled, but still clone the channel for sending
(channel.to_owned()) before/after removal as needed to preserve the OnceTake
value, and then proceed to send the NetCommand::SyncResponse via
self.tx.try_send as before.
Originally posted by @coderabbitai[bot] in #1153 (comment)
🧩 Analysis chain
🏁 Script executed:
Repository: gnosisguild/enclave
Length of output: 656
🏁 Script executed:
Repository: gnosisguild/enclave
Length of output: 916
🏁 Script executed:
Repository: gnosisguild/enclave
Length of output: 1166
🏁 Script executed:
rg -n "self\.requests" crates/net/src/net_sync_manager.rsRepository: gnosisguild/enclave
Length of output: 189
🏁 Script executed:
rg -n "requests\[|requests\.get|requests\.remove|requests\.insert" crates/net/src/net_sync_manager.rsRepository: gnosisguild/enclave
Length of output: 189
🏁 Script executed:
Repository: gnosisguild/enclave
Length of output: 2090
🏁 Script executed:
rg -n "Handler.*SyncRequestReceived|Handler.*ReceiveEvents" crates/net/src/net_sync_manager.rs -A 2Repository: gnosisguild/enclave
Length of output: 417
🏁 Script executed:
rg -n "impl Drop|impl.*Cleanup|requests\.clear\|fn drop" crates/net/src/net_sync_manager.rsRepository: gnosisguild/enclave
Length of output: 45
🏁 Script executed:
rg -n "ReceiveEvents|struct ReceiveEvents" crates/net/src/ -B 2 -A 5Repository: gnosisguild/enclave
Length of output: 1564
🏁 Script executed:
rg -n "struct ReceiveEvents" crates/net/src/ -A 10Repository: gnosisguild/enclave
Length of output: 45
🏁 Script executed:
Repository: gnosisguild/enclave
Length of output: 364
🏁 Script executed:
Repository: gnosisguild/enclave
Length of output: 1079
Remove fulfilled requests from
requeststo avoid unbounded growth.Entries are never cleared after a response is sent, causing long-running nodes to accumulate stale entries indefinitely. Change
.get()to.remove()to delete the entry from the HashMap once the response is sent. Sincechannel.to_owned()clones theOnceTakebefore removal, the sent channel remains functional.Suggested change
🤖 Prompt for AI Agents
Originally posted by @coderabbitai[bot] in #1153 (comment)