-
Notifications
You must be signed in to change notification settings - Fork 410
Fix local push reconnection logic to prevent stalled reconnections #4134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5758201
002cfdf
51be302
511984b
b33d8c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,18 +52,25 @@ final class NotificationManagerLocalPushInterfaceExtension: NSObject, Notificati | |||||||||||||
| // Track disconnected state for reconnection logic | ||||||||||||||
| switch state { | ||||||||||||||
| case .unavailable: | ||||||||||||||
| if !disconnectedServers.contains(server.identifier) { | ||||||||||||||
| let wasDisconnected = disconnectedServers.contains(server.identifier) | ||||||||||||||
| if !wasDisconnected { | ||||||||||||||
| Current.Log.info("Server \(server.identifier.rawValue) local push became unavailable") | ||||||||||||||
| Current.Log | ||||||||||||||
| .verbose( | ||||||||||||||
| "Adding server \(server.identifier.rawValue) to disconnected set. Current disconnected servers: \(disconnectedServers.map(\.rawValue))" | ||||||||||||||
| ) | ||||||||||||||
| disconnectedServers.insert(server.identifier) | ||||||||||||||
| Current.Log.verbose("Disconnected servers after insert: \(disconnectedServers.map(\.rawValue))") | ||||||||||||||
| scheduleReconnection() | ||||||||||||||
| } else { | ||||||||||||||
| Current.Log.verbose("Server \(server.identifier.rawValue) already in disconnected set") | ||||||||||||||
| } | ||||||||||||||
| // Always attempt to schedule reconnection for unavailable servers. | ||||||||||||||
| // scheduleReconnectionIfNeeded() is idempotent and will only schedule if: | ||||||||||||||
| // 1. No timer is already active (prevents duplicate timers) | ||||||||||||||
| // 2. There are disconnected servers needing reconnection | ||||||||||||||
| // This ensures both initial disconnections and failed reconnection attempts | ||||||||||||||
| // properly schedule the next attempt with appropriate backoff. | ||||||||||||||
|
||||||||||||||
| // properly schedule the next attempt with appropriate backoff. | |
| // properly schedule the next attempt with appropriate backoff and timing. |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment at line 169 exceeds the 120-character line width limit specified in the SwiftFormat configuration. This comment line should be wrapped to stay within the 120-character maximum line width.
| /// Schedules a reconnection attempt with gradual backoff if one is not already scheduled. | |
| /// Schedules a reconnection attempt with gradual backoff. | |
| /// If a reconnection is already scheduled, this method does nothing. |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments at lines 170-172 exceed the 120-character line width limit specified in the SwiftFormat configuration. These comment lines should be wrapped to stay within the 120-character maximum line width.
| /// This method is idempotent and safe to call multiple times - it will only schedule a new | |
| /// timer if one is not already active. This prevents rapid successive reconnection attempts | |
| /// and ensures proper backoff timing. | |
| /// This method is idempotent and safe to call multiple times - it will only schedule a new timer | |
| /// if one is not already active. | |
| /// This prevents rapid successive reconnection attempts and ensures proper backoff timing. |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log message at line 176 exceeds the 120-character line width limit specified in the SwiftFormat configuration. This line should be wrapped to stay within the 120-character maximum line width.
| "scheduleReconnectionIfNeeded called. Current attempt: \(reconnectionAttempt), timer active: \(reconnectionTimer != nil), disconnected servers: \(disconnectedServers.count)" | |
| "scheduleReconnectionIfNeeded called. " | |
| + "Current attempt: \(reconnectionAttempt), " | |
| + "timer active: \(reconnectionTimer != nil), " | |
| + "disconnected servers: \(disconnectedServers.count)" |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment at line 237 exceeds the 120-character line width limit specified in the SwiftFormat configuration. This comment line should be wrapped to stay within the 120-character maximum line width.
| // and scheduleReconnectionIfNeeded() will schedule the next attempt with proper backoff | |
| // and scheduleReconnectionIfNeeded() will schedule the next attempt | |
| // with proper backoff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable
wasDisconnectedis assigned but never used. It was created to replace the inline check in the if statement, but since it's only used once and the variable name doesn't add clarity beyond the original expression, consider removing it and keeping the original inline check!disconnectedServers.contains(server.identifier).