@@ -52,7 +52,7 @@ func (p *Processor) ProcessPendingNotifications(ctx context.Context, handlerCtx
52
52
return nil
53
53
}
54
54
55
- for {
55
+ for rd . Buffered () > 0 {
56
56
// Check if there's data available to read
57
57
replyType , err := rd .PeekReplyType ()
58
58
if err != nil {
@@ -130,36 +130,37 @@ func (v *VoidProcessor) UnregisterHandler(pushNotificationName string) error {
130
130
// This avoids unnecessary buffer scanning overhead.
131
131
func (v * VoidProcessor ) ProcessPendingNotifications (_ context.Context , _ NotificationHandlerContext , rd * proto.Reader ) error {
132
132
// read and discard all push notifications
133
- if rd != nil {
134
- for {
135
- replyType , err := rd .PeekReplyType ()
136
- if err != nil {
137
- // No more data available or error reading
138
- break
139
- }
133
+ if rd == nil {
134
+ return nil
135
+ }
136
+ for rd .Buffered () > 0 {
137
+ replyType , err := rd .PeekReplyType ()
138
+ if err != nil {
139
+ // No more data available or error reading
140
+ break
141
+ }
140
142
141
- // Only process push notifications (arrays starting with >)
142
- if replyType != proto .RespPush {
143
- break
144
- }
145
- // see if we should skip this notification
146
- notificationName , err := rd .PeekPushNotificationName ()
147
- if err != nil {
143
+ // Only process push notifications (arrays starting with >)
144
+ if replyType != proto .RespPush {
145
+ break
146
+ }
147
+ // see if we should skip this notification
148
+ notificationName , err := rd .PeekPushNotificationName ()
149
+ if err != nil {
150
+ break
151
+ }
152
+ if shouldSkipNotification (notificationName ) {
153
+ // discard the notification
154
+ if err := rd .DiscardNext (); err != nil {
148
155
break
149
156
}
150
- if shouldSkipNotification (notificationName ) {
151
- // discard the notification
152
- if err := rd .DiscardNext (); err != nil {
153
- break
154
- }
155
- continue
156
- }
157
+ continue
158
+ }
157
159
158
- // Read the push notification
159
- _ , err = rd .ReadReply ()
160
- if err != nil {
161
- return nil
162
- }
160
+ // Read the push notification
161
+ _ , err = rd .ReadReply ()
162
+ if err != nil {
163
+ return nil
163
164
}
164
165
}
165
166
return nil
@@ -170,7 +171,7 @@ func (v *VoidProcessor) ProcessPendingNotifications(_ context.Context, _ Notific
170
171
func shouldSkipNotification (notificationType string ) bool {
171
172
switch notificationType {
172
173
// Pub/Sub notifications - handled by pub/sub system
173
- case "message" , // Regular pub/sub message
174
+ case "message" , // Regular pub/sub message
174
175
"pmessage" , // Pattern pub/sub message
175
176
"subscribe" , // Subscription confirmation
176
177
"unsubscribe" , // Unsubscription confirmation
0 commit comments