Skip to content

Commit 67b5fd2

Browse files
authored
fix: complete parent PUT when child subscribe finishes (#2109)
1 parent 60301a1 commit 67b5fd2

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

apps/freenet-ping/app/tests/run_app_blocked_peers.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,12 @@ async fn test_ping_blocked_peers_simple() -> TestResult {
831831
// as they only varied in non-functional aspects like timeouts and logging
832832

833833
/// Solution/reference implementation for blocked peers
834+
// TODO-MUST-FIX: WebSocket connection reset during teardown - see issue #2108
835+
// Test passes functionally (PUT/GET/Subscribe/state propagation all work) but
836+
// fails with "Connection reset without closing handshake" during cleanup.
837+
// Likely a test teardown race rather than functional bug.
834838
#[tokio::test(flavor = "multi_thread")]
835-
#[ignore = "fix me"]
839+
#[ignore]
836840
async fn test_ping_blocked_peers_solution() -> TestResult {
837841
run_blocked_peers_test(BlockedPeersConfig {
838842
test_name: "solution",

crates/core/src/node/network_bridge/p2p_protoc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,13 @@ impl P2pConnManager {
976976
} => {
977977
tracing::debug!(%tx, %key, "local subscribe complete");
978978

979+
// If this is a child operation, complete it and let the parent flow handle result delivery.
980+
if op_manager.is_sub_operation(tx) {
981+
tracing::info!(%tx, %key, "completing child subscribe operation");
982+
op_manager.completed(tx);
983+
continue;
984+
}
985+
979986
if !op_manager.is_sub_operation(tx) {
980987
let response = Ok(HostResponse::ContractResponse(
981988
ContractResponse::SubscribeResponse { key, subscribed },

crates/core/src/operations/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ where
126126
"root operation awaiting child completion"
127127
);
128128

129+
// Track the root op so child completions can finish it later.
129130
op_manager
130131
.root_ops_awaiting_sub_ops()
131132
.insert(tx_id, final_state);
133+
tracing::info!(%tx_id, "root operation registered as awaiting sub-ops");
132134

133135
return Ok(None);
134136
}

crates/core/src/ring/connection_manager.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ impl ConnectionManager {
423423
self.transient_connections.contains_key(peer)
424424
}
425425

426+
#[allow(dead_code)]
427+
pub fn is_transient_addr(&self, addr: &SocketAddr) -> bool {
428+
self.transient_connections
429+
.iter()
430+
.any(|entry| entry.key().addr == *addr)
431+
}
432+
426433
pub fn transient_count(&self) -> usize {
427434
self.transient_in_use.load(Ordering::Acquire)
428435
}

0 commit comments

Comments
 (0)