@@ -84,10 +84,22 @@ pub(crate) async fn request_subscribe(
8484 tracing:: debug!( %key, "No remote peers available for subscription, checking locally" ) ;
8585
8686 if super :: has_contract ( op_manager, * key) . await ? {
87- // We have the contract locally - complete operation immediately
88- // Following Nacho's suggestion: use notify_node_event to tap into
89- // result router directly without state transitions
90- tracing:: info!( %key, tx = %id, "Contract available locally, completing subscription via result router" ) ;
87+ // We have the contract locally - register subscription and complete immediately
88+ tracing:: info!( %key, tx = %id, "Contract available locally, registering local subscription" ) ;
89+
90+ // CRITICAL FIX for issue #2001: Register subscriber in DashMap before completing
91+ // Without this, UPDATE operations won't find subscribers for locally-cached contracts
92+ let subscriber = op_manager. ring . connection_manager . own_location ( ) ;
93+ if op_manager
94+ . ring
95+ . add_subscriber ( key, subscriber. clone ( ) )
96+ . is_err ( )
97+ {
98+ tracing:: error!( %key, tx = %id, "Failed to add local subscriber - max subscribers reached" ) ;
99+ // Continue anyway - client requested subscription and contract is local
100+ } else {
101+ tracing:: debug!( %key, tx = %id, subscriber = %subscriber. peer, "Successfully registered local subscriber" ) ;
102+ }
91103
92104 // Use notify_node_event to deliver SubscribeResponse directly to client
93105 // This avoids the problem with notify_op_change overwriting the operation
0 commit comments