launchdarkly / js-core

LaunchDarkly monorepo for JavaScript SDKs
Other
14 stars 16 forks source link

LaunchDarklyClientError: Unknown feature flag on Android #472

Closed nadSTC closed 1 month ago

nadSTC commented 4 months ago

Describe the bug Getting a 'not found' error when trying to retrieve feature flags on android specifically. My project is in react native using expo. I can confirm that the exact same code works for iOS in both device and simulator. Here is how i set up my launch darkly client

I can confirm that all my flags have the SDKs using Mobile key checked as well.

import { ReactNode, useEffect } from "react";
import {
  LDProvider,
  LDContext,
  ReactNativeLDClient,
  AutoEnvAttributes,
} from "@launchdarkly/react-native-client-sdk";
import envConfig from "../util/env.config";
import { useAuth } from "./AuthContext";

const client = new ReactNativeLDClient(
  envConfig.launchDarkly.mobileKey,
  AutoEnvAttributes.Enabled
);

export const LaunchDarklyProvider = ({ children }: { children: ReactNode }) => {
  const { user } = useAuth();

  async function identify() {
    const context: LDContext = {
      kind: "user",
      key: user?.email || "anonymous",
    };
    await client.identify(context);
  }

  useEffect(() => {
    (async () => {
      await identify();
    })();
  }, [user?.email]);

  return <LDProvider client={client}>{children}</LDProvider>;
};

I'm retrieving my flag values using useBoolVariation, useStringVariation etc.

Expected behavior Feature flag values should propogate

Logs same error for all my flags in android

 LOG  error: [LaunchDarkly] error: LaunchDarklyClientError: Unknown feature flag "<featureFlagName>"; returning default value false., context: {"kind":"multi","user":{"k
ey":"anonymous"},"ld_device":{"envAttributesVersion":"1.0","manufacturer":"Google","m
odel":"sdk_gphone64_arm64","os":{"name":"android","version":"34","family":"android"},
"key":"f8f3baaa-5338-4d88-bd77-c923cd7a626c"}}

SDK version

"@launchdarkly/react-native-client-sdk": "^10.1.1",

Language version, developer tools

"react-native": "0.73.6",
"expo": "~50.0.17",

OS/platform Android

yusinto commented 4 months ago

If you are running Android in debug in the simulator, there is a known issue with Flipper blocking streaming network connections in debug mode. Please see this pinned issue and see if this resolves it.

kinyoklion commented 1 month ago

Newer RN and Expo should not encounter this issue. I've updated some readme and example information with notes about what versions function correctly in development builds.