@@ -155,7 +155,7 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
155155 channels := broadcaster .Subscribe ()
156156 defer broadcaster .CancelSubscription (channels .ID )
157157
158- var pendingRequest * broadcast.NginxAgentMessage
158+ var pendingBroadcastRequest * broadcast.NginxAgentMessage
159159
160160 for {
161161 // When a message is received over the ListenCh, it is assumed and required that the
@@ -194,17 +194,17 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
194194 return grpcStatus .Error (codes .Internal , err .Error ())
195195 }
196196
197- // Track the pending request so we don't intercept
198- // initial config replies after connection reset
199- pendingRequest = & msg
197+ // Track this broadcast request to distinguish it from initial config operations.
198+ // Only broadcast operations should signal ResponseCh for coordination.
199+ pendingBroadcastRequest = & msg
200200 case err = <- msgr .Errors ():
201201 cs .logger .Error (err , "connection error" , "pod" , conn .PodName )
202202 deployment .SetPodErrorStatus (conn .PodName , err )
203203 select {
204204 case channels .ResponseCh <- struct {}{}:
205205 default :
206206 }
207- if pendingRequest != nil {
207+ if pendingBroadcastRequest != nil {
208208 cs .logger .V (1 ).Info ("Connection error during pending request, operation failed" )
209209 }
210210
@@ -225,9 +225,10 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
225225 deployment .SetPodErrorStatus (conn .PodName , nil )
226226 }
227227
228- // Only signal completion if we had a pending broadcast request
229- if pendingRequest != nil {
230- pendingRequest = nil
228+ // Signal broadcast completion only for tracked broadcast operations.
229+ // Initial config responses are ignored to prevent spurious success messages.
230+ if pendingBroadcastRequest != nil {
231+ pendingBroadcastRequest = nil
231232 channels .ResponseCh <- struct {}{}
232233 } else {
233234 cs .logger .V (1 ).Info ("Received response for non-broadcast request (likely initial config)" , "pod" , conn .PodName )
0 commit comments