Skip to content

feat: Add contract test for streaming connection close on client shutdown - #403

Merged
jsonbailey merged 1 commit into
v3from
jb/sdk-2669/v3-close-contract-test
Aug 6, 2026
Merged

jsonbailey merged 1 commit into
v3from
jb/sdk-2669/v3-close-contract-test

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Related issues

Describe the solution you've provided

Brings the "SDK closes its streaming TCP socket when the client is closed" contract test into v3, under both the server-side and client-side streaming suites (streaming/connection lifecycle/SDK closes streaming connection when client is closed).

A straight cherry-pick of the squashed v2 commit (35acfd4) does not compile on v3: v3 removed the legacy FDv1 data-source API the original used (NewSDKDataSource, DataSourceOptionStreaming, CommonStreamingTests.setupDataSources). The test was adapted to the v3 FDv2 data-system API while preserving identical behavior:

streamTests := NewCommonStreamingTests(...)
dataSystem, configurers := streamTests.setupDataSystems(t, nil)   // was setupDataSources
client := streamTests.newFDv2SDKClient(t, configurers...)          // was NewSDKClient
endpoint := dataSystem.Synchronizers[0].Endpoint()                 // was dataSource.Endpoint()
// ... client.Close(); assert streamRequest.Context.Done() within 3s

Detection mechanism is unchanged: after client.Close(), poll the captured streaming request's Context.Done() (Go's HTTP server cancels the request Context when the client drops the underlying TCP connection); deadline 3s, poll 20ms.

The client-side variant keeps the Roku hardening from the v2 PR: it skips the short-lived POST /handshake (whose Context is already cancelled when its handler returns) so the assertion runs against the long-lived SSE connection rather than false-passing on the handshake.

Additional context

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Link to Devin session: https://app.devin.ai/sessions/a705fd8d797e40f1b07605e9a2225ebd
Requested by: @jsonbailey


Note

Low Risk
Test-only harness changes with no production runtime impact; they may cause CI failures for SDKs that still leak streaming sockets after close.

Overview
Adds a connection lifecycle subtest to both server-side and client-side streaming suites so contract CI can require SDKs to tear down the long-lived SSE connection when client.Close() runs, instead of leaving the TCP socket open.

Each test wires an FDv2 client via setupDataSystems / newFDv2SDKClient, captures the active streaming request with RequireConnection, calls Close(), then polls until that request’s Context is cancelled (Go cancels it when the client drops the connection), with a 3s deadline.

The client-side variant keeps Roku-specific handling: it skips the short-lived POST /handshake so the assertion targets the real SSE stream, not a request whose context is already done when the handler returns.

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

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot added the devin-pr PRs created by Devin label Aug 5, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

@cursor review

@jsonbailey
jsonbailey marked this pull request as ready for review August 5, 2026 22:24
@jsonbailey
jsonbailey requested a review from a team as a code owner August 5, 2026 22:24
@jsonbailey
jsonbailey merged commit 0f91b2a into v3 Aug 6, 2026
7 checks passed
@jsonbailey
jsonbailey deleted the jb/sdk-2669/v3-close-contract-test branch August 6, 2026 16:30
kinyoklion pushed a commit that referenced this pull request Aug 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[3.2.0-alpha.6](v3.1.1-alpha.6...v3.2.0-alpha.6)
(2026-08-12)


### Features

* Add contract test for streaming connection close on client shutdown
([#403](#403))
([0f91b2a](0f91b2a))
* Add contract tests for client-side secure mode hash (h query param)
([#376](#376))
([3e3012c](3e3012c))
* Add hook-environment-id capability and test
([#412](#412))
([922989a](922989a))
* Add migration op event context redaction tests
([#385](#385))
([34d68e9](34d68e9))
* add tests for handling redacting attributes prefixed with `/`
correctly
([#381](#381))
([ff6929d](ff6929d))
* Verify the in operator keeps booleans and numbers distinct
([fac2879](fac2879))


### Bug Fixes

* Correct privateAttributes JSON tag in context comparison params
([#392](#392))
([d9d2c01](d9d2c01))
* Fix capability guarding custom event redaction
([#387](#387))
([4d3419b](4d3419b))
* Only expect custom-event anonymous redaction for server SDKs
([#389](#389))
([032ae14](032ae14))
* prevent client side wrapper test datasystem from colliding with
primary connection mode
([#394](#394))
([fb40bc6](fb40bc6))

---
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-only PR** — bumps the package from `3.1.1-alpha.6` to
**`3.2.0-alpha.6`** in `.release-please-manifest.json`, `main.go`
(`versionString`), and adds the matching **CHANGELOG** section.
> 
> No harness or test code changes appear in this diff; the changelog
summarizes work already merged on the branch (new contract tests for
streaming shutdown, client-side secure mode `h` param,
hook-environment-id, migration/context redaction, `/`-prefixed attribute
redaction, and `in` operator type distinction, plus fixes for
`privateAttributes` JSON tagging, custom-event redaction capability
guards, server-only anonymous redaction expectations, and client-side
wrapper datasystem collision).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
104ac51. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devin-pr PRs created by Devin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants