react-sdk
react-sdk copied to clipboard
[BUG] Random error with initialization client
Is there an existing issue for this?
- [X] I have searched the existing issues
SDK Version
react-sdk v3.1.0
Current Behavior
We currently have logs indicating random requests getting the following error
message:Request error stack:Error: Request error at responsePromise.n.onreadystatechange
Expected Behavior
No error
Steps To Reproduce
// or this is written inside useEffect
const client = createInstance({
sdkKey: 'SDK_KEY',
datafileOptions: {
autoUpdate: true,
updateInterval: 300000,
},
eventBatchSize: 10,
eventFlushInterval: 1000,
errorHandler: {
handleError: (e: Error) => {
console.log(e.message, e.stack);
},
},
odpOptions: {
disabled: true,
},
});
const OptimizelyFlagProvider = () => {
// some useState
useEffect(() => {
const isClientValid = () => {
return client?.getOptimizelyConfig() !== null;
};
client?.onReady().then((ocInstance: OnReadyResult) => {
if (isClientValid()) {
// set valid state
}
else {
// set error state
}
}(
}, []);
return (
<OptimizelyProvider optimizely={client} timeout={500} user={{ id: 'userId' }}>
// error and successful body {....}
</OptimizelyProvider>
);
}
React Framework
18.2.0
Browsers impacted
Chrome latest version
Link
No response
Logs
No response
Severity
Affecting users
Workaround/Solution
No response
Recent Change
No response
Conflicts
No response
Hey @kimyu92! Your provided error log indicates that the client is facing network issue while synching the datafile. However, I could not reproduce the issue with your given snippet. So, if you could provide more context that would be nice.
@kimyu92 , due to inactivity, I am closing this issue. If you have more details or the issue occurs again, please feel free to reopen it.
Thanks!