Repository navigation
Conversation
6dd55ca to
458d103
Compare
dd2985a to
84ee448
Compare
| sdks: | ||
| dart: ">=3.11.0 <4.0.0" | ||
| flutter: ">=3.41.0" |
There was a problem hiding this comment.
🔍 Browser tests cannot use committed dependency graph
The lockfile requires Dart >=3.11.0 and Flutter >=3.41.0; browser-contract-tests installs 3.7.2 and 3.29.3. CI therefore resolves other dependency versions rather than exercising this lockfile.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
This matches the sibling apps/flutter_client_contract_test_service/pubspec.lock, whose footer is also above the oldest CI toolchain. CI runs melos bootstrap, which re-resolves the lock for the installed SDK, and both the 3.22.3 / 3.4.4 job and browser-contract-tests pass on this head.
| _stopping = true; | ||
| // Release the port first. The next harness run binds it while the | ||
| // browser is still on its way out. | ||
| await _server.close(); |
There was a problem hiding this comment.
🔴 Outstanding commands can block adapter shutdown
When a browser command remains unanswered, shutdown() waits for its HTTP request to finish before stopping Chrome. The request awaits a websocket reply in _rest, leaving shutdown stuck and the browser running.
Learn more
Closing an HttpServer without force waits for active HTTP requests to finish. A command request remains active while _rest awaits _send; its pending reply is completed when the browser replies or disconnects. With an unanswered command, shutdown() waits on the server before killing Chrome or closing the relay. Stopping the adapter therefore cannot release that request.
Example: A harness POST waits on a browser command that never replies, then the harness sends DELETE /. The DELETE initiates shutdown, but the POST remains active, so the adapter neither stops Chrome nor completes shutdown.
Recommended fix: Stop Chrome and close the websocket before waiting for a graceful server close, as this releases pending command requests. If the port must be released first, initiate closure without awaiting it and ensure outstanding requests are completed or use a bounded forced close.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Dart's HttpServer.close() without force only closes the listening socket and idle connections. The returned future does not wait for active requests (see _HttpServer.close in the SDK's http_impl.dart). DELETE / also runs shutdown() unawaited, and main calls exit(0) once stopped completes, so a parked command does not block the Chrome teardown.
ce1d5df to
68dc044
Compare
… 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 -->
801d6fb to
f9e3c8c
Compare
## Summary - Adds an optional `eventSource` to `LDConfig` and passes it to the common config. Exports `SSEClient` and `SseClientBuilder` from the Flutter package so an app can pass `SSEClient.http`. - The API docs describe the web default, the fallbacks it causes for `useReport` and `usePost`, and that a web build that leaves the option null does not include the HTTP-based client. Most applications do not need it. - Default behavior is unchanged when the option is not set. ## Additional context This PR also moves the exact pin of `launchdarkly_common_client` in `flutter_client_sdk` from 1.15.1 to 1.16.0, which ships the `eventSource` option on `LDCommonConfig`. This PR is the bottom of a stack. #360 builds on it. ## Related tickets - sdk-3442 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > The Flutter SDK now exposes an optional **`eventSource`** on **`LDConfig`**, forwarding to the shared common config so apps can choose which SSE client handles flag streaming. > > **`SSEClient`** and **`SseClientBuilder`** are re-exported from the package entrypoint (e.g. so web apps can pass **`SSEClient.http`** for `fetch()`-based streaming). API docs spell out the web default (`EventSource`), related fallbacks for **`useReport`** / **`usePost`**, and that leaving the option null keeps the HTTP client out of web builds. > > Behavior is unchanged when **`eventSource`** is omitted; tests assert default null and that a supplied builder is retained. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 11a4bd3. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
f9e3c8c to
b08837d
Compare
| if (segments.isNotEmpty && segments.first == _appPath) { | ||
| return staticHandler(request.change(path: _appPath)); | ||
| } | ||
| return adapter._rest(request); |
There was a problem hiding this comment.
🟥 Local processes can control test clients
Any local process can POST to Adapter and create clients with arbitrary service endpoints or stop the running service. The REST interface has no authentication despite controlling the browser and SDK network requests.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
This is a local test harness. The adapter binds to the loopback interface only, and the websocket accepts only the origin that this adapter serves. The other contract test services in this repo are also unauthenticated, and the harness cannot send credentials. Not changing.
| _profile = await Directory.systemTemp.createTemp('flutter-web-entity'); | ||
| final browser = _browser = await Process.start(executable, [ | ||
| '--headless=new', | ||
| '--no-sandbox', |
There was a problem hiding this comment.
There was a problem hiding this comment.
Headless Chrome runs in a CI container or runner, and it needs --no-sandbox there. The adapter loads only the test app that it serves itself and the SDK's test endpoints. This is a test-only tool. Not changing.
…ith application tags
…ean up Chrome on exit
…me exits and free the port on shutdown
b08837d to
91dc808
Compare
Summary
apps/flutter_web_contract_test_service, a contract test service that runs the Flutter SDK in headless Chrome. The SDK streams with the HTTP-based SSE client througheventSource: SSEClient.http. The browser nativeEventSourcecannot send a request body or report an HTTP error. This is the only contract test run that coversusePostand HTTP error handling for streaming on web.bin/adapter.dartruns on the Dart VM, serves the REST API, starts Chrome, and relays each request to a Flutter web app over a websocket. The same design is used by the JS browser SDK contract tests.client-use-postandclient-event-source-http-errorsbecause it always uses the HTTP-based SSE client. It also declarescontext-typeandpolling-gzip, which pass on web.browser-contract-teststo the CI workflow (FDv1 and FDv2 runs), and theclient-web-contract-testsandclient-web-contract-tests-fdv2melos scripts.kind: nullcontext type test, as the existing Flutter service does.Notes
auto-env-attributesis not declared, as in the JS browser SDK. Hooks are not mapped yet.lib/src/entity.dartrepeats code from the existing service. That service uses generated types that needdart:io, so it cannot share them yet.Note
Overview
Adds
apps/flutter_web_contract_test_service, a harness-facing contract test run that executes the Flutter client SDK in headless Chrome witheventSource: SSEClient.http, sousePostand HTTP streaming error scenarios are covered—behavior the native browserEventSourcepath cannot exercise.A VM
bin/adapter.dartexposes the harness REST API, serves the web build, launches Chrome, and relays requests over WebSocket to a minimallib/main.dartentity that drivesLDClientand advertises capabilities includingclient-use-postandclient-event-source-http-errors.CI gains a
browser-contract-testsjob (FDv1 + FDv2 harness runs, adapter restarts between runs, adapter log artifacts).melos.yamladdsclient-web-contract-tests/client-web-contract-tests-fdv2. Harness suppression lists (FDv1/FDv2) document web/CORS tag-header skips. The existingflutter_client_contract_test_serviceREADME documents how to run the harness locally.Reviewed by Cursor Bugbot for commit 91dc808. Bugbot is set up for automated code reviews on this repo. Configure here.