launchdarkly / js-client-sdk

LaunchDarkly Client-side SDK for Browser JavaScript
Other
113 stars 66 forks source link

Confusing error message with no keys #165

Closed jb-reefer closed 5 years ago

jb-reefer commented 5 years ago

Describe the bug When client side keys are not set, we get the following error message from the React SDK:

environment not found. Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.

This implies that the environment hasn't been configured in LD, when it has - we just don't have any keys at all!

To reproduce Instantiate an withLDProvider with clientSideID: undefined

Expected behavior A more useful error message, like "clientSideID not provided"

Logs clientSideID: LAUNCHDARKLY_CLIENT_ID,

SDK version 2.12.0 of launchdarkly-js-client-sdk

Language version, developer tools Node 10

OS/platform We see the above on all modern browsers

bwoskow-ld commented 5 years ago

Hi @jb-reefer,

Thank you for the suggestion.

Prior to getting the environment not found message, you should have had a No environment specified message when initializing withLDProvider. As that's the first place that an error occurred, that's the most important console message to note. Each subsequent flag evaluation request will fail and log a environment not found message because withLDProvider wasn't initialized correctly.

The other part which is probably causing confusion is a terminology discrepancy:

Although the name is different, they're referring to the same thing; both of these parameters should be populated with what app.launchdarkly.com and our documentation refer to as the "client-side ID". The error messages refer to them as "environment" as that's what the JavaScript SDK calls it during initialization.

To make this more clear, we're taking your suggestion and updating these two messages to refer to both environment and client-side ID. This will be included in the next version of our JS and React SDKs (likely 2.12.5).

Cheers, Ben

eli-darkly commented 5 years ago

Fixed in the 2.12.5 release.