Skip to content

Cannot read properties of undefined (reading 'loggerProvider') #1573

@axelvaindal

Description

@axelvaindal

Expected Behavior

No runtime when no loggerProvider is provider at init time.

Current Behavior

loggerProvider is undefined and the error is not handled by the SDK.


  useEffect(() => {
    const getVariants = async () => {
      if (!currentUser) {
        return
      }

      if (!initialized) {
        await initAll(ENVIRONMENT.AMPLITUDE.API_KEY, {
          serverZone: 'EU',
          analytics: {
            autocapture: false,
          },
          sessionReplay: {
            sampleRate: 0,
          },
          experiment: {
            deploymentKey: ENVIRONMENT.AMPLITUDE.DEPLOYMENT_KEY,
          },
        })

        setInitialized(true)
      }

      if (currentUser && initialized && loading) {
        const client = await experiment()?.fetch({
          user_id: String(currentUser.id),
        })

        const featureFlags = client?.all() || {}

        setVariants(featureFlags)
        setLoading(false)
      }
    }

    getVariants()
  }, [currentUser, initialized, loading])
Image

Possible Solution

Unknown.

Steps to Reproduce

  1. Add the provider to a react application
  2. Load the application
  3. The SDK sometimes fails to load a plugin somehow and when trying to log cannot find the loggerProvider

Environment

  • JS SDK Version: unified SDK 1.0.0-beta.35
  • Installation Method: yarn
  • Browser and Version: All browser and versions impacted

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions