Skip to content

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

Draft
jsonbailey wants to merge 1 commit into
v2from
jb/sdk-2669/fdv1-close-contract-test
Draft

feat: Add contract test for streaming connection close on client shutdown#377
jsonbailey wants to merge 1 commit into
v2from
jb/sdk-2669/fdv1-close-contract-test

Conversation

@jsonbailey

Copy link
Copy Markdown

Summary

Adds a new connection-lifecycle subtest to the legacy server-side streaming suite asserting that the SDK closes its streaming TCP socket when the client is closed.

  • Where it's registered: sdktests/server_side_stream_all.go, as a connection lifecycle subtest under doServerSideStreamTests (path: streaming/connection lifecycle/SDK closes streaming connection when client is closed).
  • Ungated: It is NOT behind CapabilityFDv1Fallback or any FDv2 capability. It uses a plain streaming config (NewSDKDataSource(...DataSourceOptionStreaming()) + NewSDKClient(t, dataSource), no data-system object), which exercises the legacy FDv1 streaming data source.
  • Detection mechanism: Same as the FDv2 close assertion — after client.Close(), it polls the captured streaming request's Context.Done(). Go's HTTP server cancels the incoming request Context when the client closes the underlying TCP connection. Deadline time.Second*3, poll time.Millisecond*20.
  • Double-close safe: TestServiceEntity.Close() uses sync.Once, so the explicit close plus the automatic end-of-test close do not double-DELETE.

Local validation

Run against two python-server-sdk versions on PORT 8001:

  • Buggy (python-server-sdk main): test RAN and FAILED 3/3SDK did not close the streaming connection after the client was closed. Socket stays ESTABLISHED past the 3s deadline (GC-only closure).
  • Fixed (SDK-2668 / python-server-sdk PR #456): test RAN and PASSED 3/3 — force-close of the urllib3 pool cancels the request Context near-instantly.

No flakiness observed. The CPython refcounting spurious-pass concern did not materialize: buggy main misses the deadline by a wide, reliable margin.

Needs team discussion before merge

This assertion runs against every server-side SDK, not just Python. Any SDK that shares the same un-closed connection-pool pattern on its legacy streaming path will start failing CI once this lands. Ruby is a likely candidate. This is why the PR is opened as a draft — we should confirm which SDKs currently pass/fail and coordinate fixes (or temporary gating) before merging.

References

  • Ticket: SDK-2669
  • Related fix: SDK-2668 / python-server-sdk PR #456

…down

Adds a connection-lifecycle subtest to the legacy server-side streaming
suite asserting the SDK closes its streaming TCP socket when the client is
closed, using the request Context.Done() cancellation signal. Previously
only the FDv2 directed-fallback path asserted socket closure; the legacy
FDv1 path had no equivalent coverage.
@jsonbailey jsonbailey force-pushed the jb/sdk-2669/fdv1-close-contract-test branch from c9bef55 to 9889fae Compare July 10, 2026 22:27
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.

1 participant