react-sdk icon indicating copy to clipboard operation
react-sdk copied to clipboard

[BUG] Random error with initialization client

Open kimyu-ng opened this issue 1 year ago • 1 comments

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

image

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

kimyu-ng avatar May 16 '24 15:05 kimyu-ng

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.

junaed-optimizely avatar May 17 '24 16:05 junaed-optimizely

@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!

junaed-optimizely avatar Nov 07 '24 11:11 junaed-optimizely