bland-yacht-60792
02/22/2026, 3:01 PMbackgroundSync: true on iOS, the SSE connection permanently dies after the device loses internet connectivity. Even after connectivity is restored, the setRefreshHandler is never called again for any future feature flag changes. The only workaround we found was killing and relaunching the app.
My current solution:
I listen for network connectivity restoration using NWPathMonitor and reinitialize the entire SDK instance when internet comes back:
private func setupNetworkMonitor() {
reachabilityCancellable = networkMonitor.stateSubject
.removeDuplicates()
.sink { [weak self] state in
guard let self else { return }
switch state {
case .connected:
guard self.isNetworkDisconnected else { return }
self.isNetworkDisconnected = false
self.initializeSDKInstance() // creates a fresh GrowthBookSDK
case .notConnected:
self.isNetworkDisconnected = true
}
}
}
My Questions:
1. Does backgroundSync: true have any built-in SSE reconnection logic after network loss, or is reinitializing the SDK the expected approach?
2. Is it safe to replace sdkInstance with a new instance on every disconnect/reconnect cycle? We're concerned about memory, pending callbacks from the old instance, or any internal state that should be preservedpowerful-spoon-16837
02/23/2026, 1:25 PMbackgroundSync: true - it should automatically reconnect after network loss.
Could you double-check the SSE URL being passed to the SDK is correct and reachable? We've seen cases where an incorrect or malformed SSE URL causes the connection silently fail, which looks exactly like the symptoms you're describing
As for reinitializing the SDK instance - yes, it's safe to replace sdkInstance with a new one. The SDK doesn't hold global shared state, so the old one will be deallocated normally as long as you don't keep other strong references to it. That said, if the reconnection logic works correctly with the right URL, you shouldn't need the NWPathMonitor workaround at all.bland-yacht-60792
02/23/2026, 2:22 PMinitializeSDKInstance() implementation:
private func initializeSDKInstance() {
sdkInstance = GrowthBookBuilder(
apiHost: "<https://cdn.growthbook.io>",
clientKey: ,
attributes: [:],
trackingCallback: { experiment, experimentResult in
dLog("Experiment Id: ", experiment.key)
dLog("Variation Id: ", experimentResult.variationId)
},
backgroundSync: true)
.setRefreshHandler(refreshHandler: { isRefreshed in
dLog(isRefreshed)
})
.initializer()
}powerful-spoon-16837
02/24/2026, 9:56 AM