@launchdarkly/react-sdk - v4.2.2
    Preparing search index...

    Variable fetchBrowserEventSourceConst

    fetchBrowserEventSource: LDEventSourceFactory

    An LDEventSourceFactory that produces a fetch()-based EventSource instead of the native browser one.

    Unlike the native browser EventSource, this one can send request headers, use a method other than GET with a request body, and apply a read timeout. The custom method support is what lets the FDv2 usePost option stream evaluations over POST and the FDv1 useReport option stream them over REPORT. It requires fetch(), AbortController and a streaming Response.body, which all current browsers provide.

    It never sends the x-launchdarkly-tags header on the streaming request. The LaunchDarkly streaming service's CORS allow-list does not include that header, so a request with it cannot connect.

    It also gives the SDK the HTTP status and headers of a failed streaming request. The SDK uses them to handle the failure. For example, it reports a 401 or 403 response as an error, not as a network failure. The native browser EventSource does not expose them, so with it the SDK treats every streaming failure as a network failure and retries.

    It is not the default. Pass it as the eventSource option to opt in:

    import { createClient } from '@launchdarkly/js-client-sdk';
    import { fetchBrowserEventSource } from '@launchdarkly/js-client-sdk/fetch-eventsource';

    const client = createClient(clientSideId, context, { eventSource: fetchBrowserEventSource });