Repository navigation
feat: Add eventSource to LDConfig - #359
Merged
Merged
Conversation
joker23
force-pushed
the
skz/sdk-3442/event-source-factory-config
branch
5 times, most recently
from
November 5, 2026 18:02
5600aed to
144b3e7
Compare
joker23
force-pushed
the
skz/sdk-3442/event-source-factory-config
branch
4 times, most recently
from
November 5, 2026 22:48
6f9380a to
3d8a31d
Compare
joker23
marked this pull request as ready for review
November 5, 2026 22:54
joker23
force-pushed
the
skz/sdk-3442/event-source-factory-config
branch
2 times, most recently
from
November 9, 2026 14:55
d2be8ea to
909eabb
Compare
joker23
force-pushed
the
skz/sdk-3442/event-source-factory-config
branch
3 times, most recently
from
November 10, 2026 20:44
2b1de79 to
9869a58
Compare
joker23
added a commit
that referenced
this pull request
Nov 12, 2026
… streaming (#358) ## Summary - Adds `eventSource` to `LDCommonConfig`, an optional `SseClientBuilder`. When it is null, the SDK uses the default client for the platform. On web, that is the browser `EventSource`, which cannot send a request body or report an HTTP error. An app passes `SSEClient.http` to stream with `fetch()` instead, so `useReport` and `usePost` work on web. On other platforms the default client is already `SSEClient.http`. - The app passes the implementation, so a web build that leaves the option null never references the HTTP SSE client and the compiler removes it. A runtime bool would keep both clients reachable. Measured with `dart compile js -O2` against `common_client`: 324 KB without the option, 354 KB with `SSEClient.http`. - `SSEClient` and `SseClientBuilder` are exported from `common_client`. No other SSE type is exported. - A supplied builder is treated as able to send POST and REPORT. Without one, `useReport` on web falls back to GET with a warning, and `usePost` on web skips the streaming sources and polls, as before. - On web, the SDK drops the application tags header from the streaming request. The CORS allow-list of the streaming service does not include it. The unused `streamingReportSupported` platform getters are removed. - FDv1 streaming uses the client-side ID as the environment ID when the connect headers are present but lack it, as happens after CORS filtering. - Both streaming data sources build their client through the same builder type, so tests inject a fake client the same way on both paths. - Adds a Chrome test file for the web-only decisions and a CI step that runs it with `dart test -p chrome`. ## Additional context This PR moves the exact pin of `launchdarkly_event_source_client` in `common_client` from 3.0.1 to 3.1.0, which ships `SSEClient.http`. This PR is the bottom of a stack. #359 and #360 build on it. ## Related tickets - sdk-3441 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > Adds **`LDCommonConfig.eventSource`**, an optional `SseClientBuilder`, and wires it through FDv1 `StreamingDataSource` and FDv2 `FDv2DataSystem` so apps can supply **`SSEClient.http`** on web and enable **POST/REPORT** streaming instead of default browser **GET** or polling fallbacks. > > Introduces **`streaming_client.dart`** with shared **`streamingRequestHeaders`** (drops **`x-launchdarkly-tags`** on web for CORS) and **`streamingCustomMethodSupported`** to decide POST/REPORT vs fallbacks. Platform defaults replace **`streamingReportSupported`** with **`streamingPostSupported`** and **`streamingTagsHeaderSupported`**. FDv1 streaming now falls back to the client-side ID for environment ID when connect headers omit it after CORS filtering. > > Exports **`SseClientBuilder`** and **`SSEClient`**, bumps **`launchdarkly_event_source_client`** to **3.1.0**, and adds Chrome CI plus VM/browser tests for web-only streaming behavior. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1cfae3d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
joker23
force-pushed
the
skz/sdk-3442/event-source-factory-config
branch
from
November 12, 2026 16:48
9869a58 to
11a4bd3
Compare
kinyoklion
approved these changes
Nov 12, 2026
…tory docs - Event, MessageEvent and OpenEvent collide with package:web and dart:html in web apps. Only an SSEClient implementer needs them. - The LDConfig doc links to the SSEClientFactory contract and warns not to log the request. - The example states why it opts in to the HTTP client on web. - Add an export test and a start-to-close test for the factory.
…ce option that supplies the SSE client
…n send a request body
joker23
force-pushed
the
skz/sdk-3442/event-source-factory-config
branch
from
November 12, 2026 19:12
11a4bd3 to
6be783a
Compare
Contributor
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ Custom streaming clients survive source shutdown
When a context changes or streaming stops, StreamingDataSource never closes the supplied SSEClient. Canceling its subscription does not release resources owned outside that subscription.
joker23
pushed a commit
that referenced
this pull request
Nov 12, 2026
🤖 I have created a release *beep* *boop* --- ## [4.22.0](4.21.1...4.22.0) (2026-11-12) ### Features * Add eventSource to LDConfig ([#359](#359)) ([3f36279](3f36279)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
eventSourcetoLDConfigand passes it to the common config. ExportsSSEClientandSseClientBuilderfrom the Flutter package so an app can passSSEClient.http.useReportandusePost, and that a web build that leaves the option null does not include the HTTP-based client. Most applications do not need it.Additional context
This PR also moves the exact pin of
launchdarkly_common_clientinflutter_client_sdkfrom 1.15.1 to 1.16.0, which ships theeventSourceoption onLDCommonConfig.This PR is the bottom of a stack. #360 builds on it.
Related tickets
Note
Overview
The Flutter SDK now exposes an optional
eventSourceonLDConfig, forwarding to the shared common config so apps can choose which SSE client handles flag streaming.SSEClientandSseClientBuilderare re-exported from the package entrypoint (e.g. so web apps can passSSEClient.httpforfetch()-based streaming). API docs spell out the web default (EventSource), related fallbacks foruseReport/usePost, and that leaving the option null keeps the HTTP client out of web builds.Behavior is unchanged when
eventSourceis omitted; tests assert default null and that a supplied builder is retained.Reviewed by Cursor Bugbot for commit 11a4bd3. Bugbot is set up for automated code reviews on this repo. Configure here.