Hi Team, a large Enterprise customer is facing an ...
# sdk-flutter
f
Hi Team, a large Enterprise customer is facing an issue with the refreshHandler only triggered during initialization. They are using 3.9.14 and looking at thread here another customer faced the same. Please can you review this?
CC @freezing-postman-69602 as this is for one of our large strategic customers
m
cc: @calm-dog-24239
🙌 1
c
Hi @flaky-noon-11399. Yes, sure, we will take a look on that.
f
Thank you both 🙏🏾
🙌 1
c
Hi @flaky-noon-11399 . Could you please ask the client to upgrade to 4.0.0?
f
Thank you Maxim, will do 🙏🏾
🙌 1
Hi @calm-dog-24239, the customer responded that they can't update because "cannot since we havent use that version of flutter and dart"
c
We will find some solution for that. Let us check that.
Could you please ask the client what version of dart and flutter they are using? It will really helps us.
f
Thank you, they said 3.22.3
🙌 1
c
Thank you very much
f
My pleasure 🌻
🙌 1
c
We have prepared alpha release here with that version of Flutter for the client : https://github.com/growthbook/growthbook-flutter/pull/120 @freezing-postman-69602 could you please take a look on that when you will have a time?
f
Thank you @calm-dog-24239 🙏
🙌 1
c
You are welcome
🫶 1
Hi @flaky-noon-11399. We have prepared alpha release for this client here. Hope it will help and looking forward for your feedback.
In this release he could use SDK on the lower version of Dart and Flutter.
f
Amazing, thank you @calm-dog-24239 🚀
🙌 1
c
You are welcome
f
Hi @calm-dog-24239, the customer confirmed that the refresh handler is triggered now However, they've asked when this (refresh Handler) is supposed to be triggered? Right now, every time they initialise the GrowthBook SDK, they've noticed it will trigger like 10+ times initially. When they change some flag values from the dashboard, the refresh handler is also triggered multiple times too If they use remote eval, does it not support background sync?
🙌 1
c
Hi @flaky-noon-11399. Please let us check and I will write to you.
The
refreshHandler
is expected to be called whenever the GrowthBook SDK fetches or refreshes features. • This happens during SDK initialization (when features are first loaded from the API or cache). • It also happens whenever the SDK pulls new data (for example, after flags are updated on the dashboard). The reason you are currently seeing it fire multiple times is that: 1. On app startup, the SDK may trigger multiple UI re-renders depending on how
feature()
calls are used in your app. Each of those may cause the refreshHandler to run. 2. If you are using background sync (via Server-Sent Events or polling), then each incoming update from the server will also trigger the refreshHandler. 3. With Remote Eval, background sync is not supported — features are only fetched when you explicitly call
fetchFeatures()
. In a typical setup, you should expect: • One refreshHandler call at initialization, when features are loaded. • One refreshHandler call per update (e.g. when you change a flag in the dashboard and the SDK receives the update). If you are seeing 10+ calls on initialization, that usually indicates the app is rebuilding the UI several times on startup and calling
feature()
during build. That can be optimized so the handler is only fired once per actual data refresh.
f
Thank you @calm-dog-24239, that's super 🙏
🙌 1
Hi @calm-dog-24239 the customer had the attached follow up:
Are there any solutions for this?
c
Hi @flaky-noon-11399 . Please let us check that and we will write to you.
Hi @flaky-noon-11399. Here is a pull request with a solution. Looking forward for your feedback.
f
Thank you @calm-dog-24239 🚀
🙌 1
Hey @calm-dog-24239 the customer asked is there an ETA when this may go live? Looks like Madhu reviewed it yesterday and there's a few edits
c
Hi @flaky-noon-11399. We will add changes and provide updates asap. Hope it will be by Thursday.
f
Ah brilliant, thank you @calm-dog-24239 🙌
🙌 1
Hey @calm-dog-24239 the customer said they experienced this on the alpha release, is this expected?
Does this solution accommodate this?
c
Hi @flaky-noon-11399. Please let us check that and I will write.
thankyou 1
We assume that we will include those versions in the main repository, not only in the alpha branch, because it would be difficult to maintain two separate branches with all the fixes.
f
Looping in @freezing-postman-69602 here so she can advise the best course of action
🙌 1
c
HI @flaky-noon-11399. Thank you. I think the best option will decrease this versions in the main version.
f
the version downgrade changes we did earlier were merged to main already. So any new versions will be compatible.
🙌 1
c
Hi @freezing-postman-69602. Yes, it was already merged. We just needed to make a GitHub release so that customers know what we’ve added. We’ve already done that as well. Thank you.
f
Hi Team, thank you, does this offer a solution for the refresh/refreshForRemoteEval method issue they reported here:
c
Hi @flaky-noon-11399. Thank you for the quick feedback. For making changes live for this issue we need to approve this pull request. Could you please @freezing-postman-69602 help us with that? We have provided there improvements: • an
_isFetching
flag in the FeatureViewModel to prevent multiple concurrent network requests. • This resolves the issue of excessive refreshHandler calls on app startup when the TTL has expired, ensuring that background revalidation occurs only once. • a
lastKnownId
variable to avoid handling duplicate data in the SSE flow.
f
Lovely, thank you Maxim. I'll get Madhu looped in 🙏
🙌 1
c
Thank you
q
hi @calm-dog-24239, i thinkk this issue will be different than the one you fix. we're having 2 issue and i believe the fix above is for the first issue? the second issue is, the refresh / refreshForRemoteEval method is not triggering another api call to refetch the latest value. cmiiw, but since remote eval depends on the attributes getting send in the payload. if i have new attributes in the client that might change the evaluation, will need another call to the remote server to get the latest value right? but for the issue above, manually calling refreshForremoteeval after setting the attributes didnt trigger any api call..
c
Hi @quiet-activity-40974. Please let me check that with team and I will write to you.
The fix was related to the refresh handler being triggered multiple times instead of once, so it addressed only that specific handler. As for the issue with the
refresh
/
refreshForRemoteEval
methods — according to the conversation, they’re using the remote eval functionality, and the API call isn’t happening. A possible reason might be that
remoteEval: true
wasn’t passed in the Growthbook Builder configuration, which would prevent the requests from being made. Could you please recheck if we’re passing it?
q
do u mean when initializing the gb instance? yes already pass it. becaause the first call was ok
c
Oh got it. thank you. We will try to reproduce that and find what the issue we have and also provide solution for it.
Hi @quiet-activity-40974. Could you please try this solution and let us know if it works for you? We’re looking forward to your feedback.
q
have some issue @calm-dog-24239
c
Thank you for the update, we will check that.
Could you please try this command? flutter pub run build_runner build --delete-conflicting-outputs
q
i think that should be run in your side right? @calm-dog-24239
c
This is mostly because of cached local files on your computer. Could you please try and let us know if it helps?
Sorry, we’d be happy to do it on our side, but we can’t because we don’t push generated files to GitHub. We’re looking forward to your feedback on this.
q
running it is not affecting in our app because its a lib for us @calm-dog-24239. i can see if i use from pub dev the .g is there, can we have the same thing? if i refer to ur branch, the generated file is not exist
any update? @calm-dog-24239
c
Hi @quiet-activity-40974. We have pushed the updated files. Could you please pull the latest changes from the repository?
q
still not updated. its always going to this block. i presume the _ongoingFetch didnt getting cleared when the initial fetch is finished. seems its due to the custom clientt that i use, will get back on this
thanks its shown that the api has called now @calm-dog-24239. and the value in the response already expected. but right now after i refresh, and trigger the sdk.feature, it will return this as source
Copy code
// CyclicPrerequisite Value for the Feature is being processed
cyclicPrerequisite("cyclicPrerequisite"),
what can cause this ya? this resulting the value always null
ah its solved by using evalFeature. is there any cons using this one instead of .feature ?
c
Please let us check that and I will write asap.
Hi @quiet-activity-40974 . The issue is now fixed in the same PR. The problem was that feature() wasn't clearing the internal evaluation stack, causing false cyclicPrerequisite errors. It now works correctly. Both feature() and evalFeature() work the same way now, but feature() is the recommended method because: It's the standard API across all GrowthBook SDKsIt automatically fetches fresh features from the network if the cache has expired (background refresh)evalFeature() doesn't trigger background refreshes, so you might get stale feature values. Looking forward for your feedback.