Skip to content

[BUG] Random error with initialization client #263

@kimyu-ng

Description

@kimyu-ng

Is there an existing issue for this?

  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions