Affected: Electron, JavaScript, Node.js, React Web client-side SDKs
Overview
When you bootstrap a client-side SDK with a server-generated payload, the
reason field returned by variationDetail may always be null, even if you have set evaluationReasons: true in your client-side SDK options.This happens because the server-side
allFlagsState method does not include evaluation reasons in its output by default. The evaluationReasons option on the client controls whether the SDK requests reasons from LaunchDarkly on subsequent flag fetches, but it has no effect on the data already present in the bootstrap payload. If reasons are not included in that payload, they are unavailable until the SDK has completed its first connection to LaunchDarkly and fetched fresh flag data.Solution
To include evaluation reasons in your bootstrap payload, enable the "with reasons" option when calling
allFlagsState in your server-side code. The exact option name varies by SDK:- Node.js (server-side):
withReasons: true - Java:
FlagsStateOption.WITH_REASONS - Go:
flagstate.OptionWithReasons() - .NET:
FlagsStateOption.WithReasons - Ruby:
with_reasons: true - Python:
with_reasons=True
With the "with reasons" option included in the
allFlagsState call, the bootstrap payload contains evaluation reason data and variationDetail can return it immediately on initialization, before the client has connected to LaunchDarkly.
Note: Flags that are not configured to be accessible to client-side SDKs are excluded from the
allFlagsState payload when clientSideOnly: true (or the equivalent option) is set or if client-side SDK availability is disabled in the LaunchDarkly UI.