Issue
When using JavaScript SDK in Browser, the SDK status will mostly return Not Ready when users are on a slow Network (for example 3G).
Root Cause
It's taking long time for the SDK to fetch the feature flags and Segments Information data from Split cloud due to slow network, which might cause control treatments.
Solution
To resolve this issue, we need to Increase the startup.readyTimeout value to ensure it covers the SDK fetching Split configuration time
As explained in https://docs.split.io/docs/javascript-sdk-overview under Configuration section, the default value for startup.requestTimeoutBeforeReady is 1.5 seconds.
Follow the steps below to implement the solution:
- Find out how long it takes the browser to fetch the Split configuration under slow Network, Chrome Dev tools can be used to simulate 3G Network.
- Make sure to enable the Java SDK console debug logging by running the following command in the browser Javascript console:
localStorage.splitio_debug = 'on'
- Load your page and check the debug logging, look for the following line:
[TIME TRACKER]: [Fetching - Splits] took xxxx ms to finish
Where xxxx is the total time in milliseconds.
- Now set the requestTimeoutBeforeReady and readyTimeout parameters to a higher value than the total fetching time.
Here is an example:
var sdk = SplitFactory({
startup: {
requestTimeoutBeforeReady: 5,
readyTimeout: 5
},
- In addition to the above, enable using the browser cache to store the Split configuration, to avoid using the network each time the Split configuration data is needed.
You only need to specify the the structure below when initializing your SDK object:
storage: {
type: 'LOCALSTORAGE',
prefix: 'MYPREFIX'
},
Comments
0 comments
Please sign in to leave a comment.