Skip to content

feat: Add an HTTP-based SSE client that works on web - #357

Open
joker23 wants to merge 5 commits into
mainfrom
skz/sdk-3440/http-sse-client-web
Open

joker23 wants to merge 5 commits into
mainfrom
skz/sdk-3440/http-sse-client-web

Conversation

@joker23

@joker23 joker23 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds SSEClient.http. It always returns the HTTP-based client, on every platform including web. On web it streams with fetch() through package:http, so it can send a request body, a method other than GET, and custom headers, and it can report HTTP errors. The default client on web stays the browser EventSource.
  • On web, SSEClient.http sends accept and cache-control: no-cache, like the LaunchDarkly browser SDK. The cache-control header stops a browser from serving a cached stream response on a reconnect. It costs a preflight request, which the streaming service allows and the browser caches for five minutes.
  • Raises http to ^1.6.0. Older versions use XHR on web and cannot stream.
  • No member is added to SSEClient, so classes that implement it keep compiling. The default client is unchanged on every platform.

Verification and limits

  • A program that calls SSEClient.http compiles with dart compile js.
  • Not verified: in a real browser, whether close() aborts the in-flight fetch.

This is the first PR in a stack. The next PR adds the useHttpStreamingOnWeb option to common_client.


Note

Overview
Adds SSEClient.http, a factory that always uses the HttpSseClient path (including on web via package:http / fetch()), so callers can use custom headers, non-GET methods, request bodies, and HTTP error reporting where the default web EventSource client cannot. The default SSEClient(...) factory is unchanged on every platform.

Web-specific defaults for SSEClient.http live in httpSseClientHeaders: accept and cache-control: no-cache (no user-agent), aligned with the LaunchDarkly browser SDK; caller headers still override defaults. http is raised to ^1.6.0 for web streaming, and CI runs http_sse_headers_test.dart on Chrome.

Also fixes a timeout path bug in state_connecting.dart where client.close was referenced instead of client.close(), and documents how SSEClient.http differs from native web EventSource for errors and CORS.

Reviewed by Cursor Bugbot for commit 25bd0b4. Bugbot is set up for automated code reviews on this repo. Configure here.

@joker23
joker23 added this pull request to stack #361 November 2, 2026 20:17
@joker23 joker23 changed the title skz/sdk 3440/http sse client web feat: Add an HTTP-based SSE client that works on web Nov 2, 2026
@joker23
joker23 force-pushed the skz/sdk-3440/http-sse-client-web branch 2 times, most recently from ca7e1e3 to dcf312a Compare November 4, 2026 15:19
@joker23
joker23 force-pushed the skz/sdk-3440/http-sse-client-web branch from dcf312a to 2d6ef48 Compare November 4, 2026 19:16
@joker23
joker23 marked this pull request as ready for review November 5, 2026 15:38
@joker23
joker23 requested a review from a team as a code owner November 5, 2026 15:38

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Devin Review

Comment on lines +215 to +217
return http_client.HttpSseClient(uri, eventTypes, mergedHeaders,
connectTimeout, readTimeout, body, httpMethod.toString(), logger,
uriProvider: uriProvider);

@devin-ai-integration devin-ai-integration Bot Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟨 Web stream credentials enter debug logs

When SSEClient.http receives a token-bearing URL and a logger, StateConnecting logs the full URL. Browser logs can expose that token.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pre-existing and whatever is in the url string should not be an actual secret.

@joker23
joker23 marked this pull request as draft November 5, 2026 16:42
@joker23
joker23 marked this pull request as ready for review November 5, 2026 21:01
relative: true
source: path
version: "2.0.1"
version: "3.0.1"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: updating this to the latest in main

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants