witty-rocket-75751
11/18/2025, 6:57 AMfailed to lookup host , and wanted to implement a retry mechanism when initialization fails. GBSDKBuilder provides a failure callback but seems like there is no init retry mechanism build around failure handling, our init logic is written in a singleton pattern so creation new object if init fails doesn't seem viable either, so wanted to understand how can we tackle this problem are there any helpful inbuild methods whcih gb provides for init retry?fresh-football-47124
witty-rocket-75751
11/20/2025, 9:46 AMfreezing-postman-69602
11/20/2025, 1:55 PMgbFeatures parameter, if only the calls made at initialization are failing. Here's a sample:
final defaultFeatures = <String, GBFeature>{
'feature_key': GBFeature(defaultValue: true),
// Add your fallback features
};
final sdk = await GBSDKBuilderApp(
apiKey: 'your_api_key',
hostURL: 'your_host_url',
growthBookTrackingCallBack: (experiment, result) {},
gbFeatures: defaultFeatures, // Fallback features
onInitializationFailure: (error) {
// Handle failure
},
).initialize();
2) Reload Strategies - Automatic vs Manual
• if you enable backgroundSync: true , the sdk will use SSE to update the features as and when there's a change.
• Or Use the method - refresh() to trigger this fetch manually. Here's an example of how you can do this with an exponential back-off and a refreshHandler.
GBSDKBuilderApp(
// ... other params
onInitializationFailure: (error) async {
if (error?.error.toString().contains('failed to lookup host') ?? false) {
await _retryWithBackoff();
}
},
).setRefreshHandler((isSuccess) {
if (!isSuccess) {
// Schedule retry
Future.delayed(Duration(seconds: 5), () => sdk.refresh());
}
}).initialize();
Future<void> _retryWithBackoff() async {
for (int i = 0; i < 3; i++) {
await Future.delayed(Duration(seconds: math.pow(2, i).toInt()));
await sdk.refresh();
}
}freezing-postman-69602
11/20/2025, 1:55 PMwitty-rocket-75751
11/20/2025, 4:55 PMwitty-rocket-75751
11/28/2025, 5:19 AMwitty-rocket-75751
12/01/2025, 11:01 AMfreezing-postman-69602
12/11/2025, 7:05 PM