Repository navigation
feat: Add an eventSource option that supplies the SSE client used for streaming - #358
Conversation
e161c65 to
7896553
Compare
128eff9 to
2c30ca9
Compare
c298b80 to
d4c9d97
Compare
There was a problem hiding this comment.
🔴 Ping polls fail after REPORT fallback
On web without HTTP streaming, useReport makes the stream fall back to GET, but _requestor also uses GET. Requestor still selects the REPORT polling path, so ping polls omit the context body and fail.
Learn more
A ping event asks Requestor to fetch all flags using the polling configuration, independently of the stream's HTTP method. When the browser stream falls back from REPORT to GET, _useReport becomes false, but pollingDataSourceConfig.useReport stays true. Requestor chooses the REPORT polling path from that config, while the new method and context select GET; the request carries no context for the REPORT endpoint.
Example: On web, configure FDv1 useReport: true and leave useHttpStreamingOnWeb: false. A ping triggers GET /msdk/evalx/context without a body instead of REPORT /msdk/evalx/context with the JSON context.
Recommended fix: Give Requestor the context encoding and RequestMethod derived from pollingDataSourceConfig.useReport, not _useReport. Keep the GET fallback limited to the streaming URI, body, and method. Add a browser ping-poll regression test.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Pre-existing on trunk (same _useReport fallback and Requestor construction). Kept out of this PR to keep the diff scoped. Tracked in SDK-3484.
There was a problem hiding this comment.
🔴 Stopped streams leave SSE clients open
When a stream stops, stop() cancels its listener but never closes _client. Each context switch leaves the client's control streams open instead of releasing its resources.
Learn more
The streaming data source owns the SSE client it creates on start(). Canceling the subscription stops the active connection, but HttpSseClient.close also closes its internal controllers; the cancellation path does not do that. DataSourceManager invokes stop() whenever it replaces a source, so an application that identifies multiple contexts leaves each previous SSE client unclosed.
Example: Identify user A, then user B, then user C in streaming mode. Each old source cancels its subscription, but neither A's nor B's SSE client receives close().
Recommended fix: Close the owned SSE client on stop(), clear _client, and handle asynchronous close failures without letting them escape the synchronous stop path.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Pre-existing on trunk (stop() only cancels the subscription there too). Deferred to keep this PR scoped. Tracked in SDK-3485.
ec58405 to
4a58c8b
Compare
…ders lack it on web
…hat supplies the SSE client
…seReport or usePost
4a58c8b to
1cfae3d
Compare
🤖 I have created a release *beep* *boop* --- ## [1.16.0](launchdarkly_common_client-v1.15.1...launchdarkly_common_client-v1.16.0) (2026-11-12) ### Features * Add an eventSource option that supplies the SSE client used for streaming ([#358](#358)) ([b1e0b13](b1e0b13)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > **Release PR** that publishes `launchdarkly_common_client` **1.16.0** via Release Please: bumps the package version in `pubspec.yaml`, updates `.release-please-manifest.json`, and adds a changelog entry for this release. > > The changelog records the shipped feature from [#358](#358): an **`eventSource`** configuration option so callers can supply the SSE client used for FDv2 streaming (defaulting to the built-in client when omitted). No runtime code changes appear in this diff—only release bookkeeping. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a7b18cc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Summary
eventSourcetoLDCommonConfig, an optionalSseClientBuilder. When it is null, the SDK uses the default client for the platform. On web, that is the browserEventSource, which cannot send a request body or report an HTTP error. An app passesSSEClient.httpto stream withfetch()instead, souseReportandusePostwork on web. On other platforms the default client is alreadySSEClient.http.dart compile js -O2againstcommon_client: 324 KB without the option, 354 KB withSSEClient.http.SSEClientandSseClientBuilderare exported fromcommon_client. No other SSE type is exported.useReporton web falls back to GET with a warning, andusePoston web skips the streaming sources and polls, as before.streamingReportSupportedplatform getters are removed.dart test -p chrome.Additional context
This PR moves the exact pin of
launchdarkly_event_source_clientincommon_clientfrom 3.0.1 to 3.1.0, which shipsSSEClient.http.This PR is the bottom of a stack. #359 and #360 build on it.
Related tickets
Note
Overview
Adds
LDCommonConfig.eventSource, an optionalSseClientBuilder, and wires it through FDv1StreamingDataSourceand FDv2FDv2DataSystemso apps can supplySSEClient.httpon web and enable POST/REPORT streaming instead of default browser GET or polling fallbacks.Introduces
streaming_client.dartwith sharedstreamingRequestHeaders(dropsx-launchdarkly-tagson web for CORS) andstreamingCustomMethodSupportedto decide POST/REPORT vs fallbacks. Platform defaults replacestreamingReportSupportedwithstreamingPostSupportedandstreamingTagsHeaderSupported. FDv1 streaming now falls back to the client-side ID for environment ID when connect headers omit it after CORS filtering.Exports
SseClientBuilderandSSEClient, bumpslaunchdarkly_event_source_clientto 3.1.0, and adds Chrome CI plus VM/browser tests for web-only streaming behavior.Reviewed by Cursor Bugbot for commit 1cfae3d. Bugbot is set up for automated code reviews on this repo. Configure here.