Skip to content

feat(http-client-python): make SSE reconnection opt-in - #12150

Merged
Libba Lawrence (l0lawrence) merged 3 commits into
microsoft:mainfrom
l0lawrence:l0lawrence-python-sse-reconnect-flag
Oct 13, 2026
Merged

Libba Lawrence (l0lawrence) merged 3 commits into
microsoft:mainfrom
l0lawrence:l0lawrence-python-sse-reconnect-flag

Conversation

@l0lawrence

@l0lawrence Libba Lawrence (l0lawrence) commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

mock api test failing bc typespec-azure doesnt recognize the flag and that we have it set to false

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added meta:website TypeSpec.io updates emitter:client:python Issue for the Python client emitter: @typespec/http-client-python labels Oct 9, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@12150

commit: b440a26

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-python
Show changes

@typespec/http-client-python - feature ✏️

Make automatic SSE reconnection opt-in with the enable-sse-reconnect emitter option, which defaults to false. Without this option, SSE streams end at EOF without reconnect callbacks, retry delays, or Last-Event-ID request plumbing. SSE parsing, event ID and retry metadata (including metadata-only blocks), terminal events, and stream cleanup remain available.,> ,> Enable reconnection when generating the client:,> ,> yaml,> emit:,> - "@typespec/http-client-python",> options:,> "@typespec/http-client-python":,> enable-sse-reconnect: true,>

@azure-sdk-automation

azure-sdk-automation Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Python emitter diff

Baseline gh:79ca62c01a9736ee89e5f32c2f3c744f1ae21f89 vs this PR.

Diff summary: 79 file(s), +15437 / -230

Rendered diff: inline on the run summary, or the emitter-diff-html artifact.

Informational check (eng/emitter-diff); does not block the PR.

Merge upstream main to align core dependencies with the Azure integration workspace. Register the default-off SSE fixture namespace for spell checking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

🟡 Changes recommended

Non-reconnecting streams lose metadata-only SSE state, and the breaking default change is incorrectly categorized as a feature.

2 open findings
What changed in this PR

Makes Python SSE reconnection opt-in while preserving SSE metadata and stream cleanup.

Changes:

  • Adds the enable-sse-reconnect emitter option, defaulting to false.
  • Conditionally generates reconnection runtime code and imports.
  • Adds unit, emitter, and mock API coverage plus documentation.
File Description
.chronus/​changes/​python-sse-reconnect-option.md Adds the release note.
cspell.yaml Allows the new test namespace.
packages/​http-client-python/​README.md Documents the option.
packages/​http-client-python/​emitter/​src/​emitter.ts Applies the default.
packages/​http-client-python/​emitter/​src/​lib.ts Defines the option schema.
packages/​http-client-python/​emitter/​test/​emitter.test.ts Tests validation and propagation.
packages/​http-client-python/​emitter/​test/​test-host.ts Exposes command arguments to tests.
packages/​http-client-python/​eng/​scripts/​ci/​regenerate-common.ts Generates reconnecting and non-reconnecting clients.
packages/​http-client-python/​generator/​pygen/​__init__.py Adds generator validation and default.
packages/​http-client-python/​generator/​pygen/​codegen/​models/​response.py Gates reconnect imports.
packages/​http-client-python/​generator/​pygen/​codegen/​serializers/​builder_serializer.py Gates reconnect request generation.
packages/​http-client-python/​generator/​pygen/​codegen/​templates/​streaming_base.py.jinja2 Conditionally emits reconnect runtime behavior.
packages/​http-client-python/​tests/​mock_api/​shared/​asynctests/​test_streaming_sse_async.py Tests async default behavior.
packages/​http-client-python/​tests/​mock_api/​shared/​test_streaming_sse.py Tests sync default behavior.
packages/​http-client-python/​tests/​unit/​test_options_dict.py Tests option parsing and validation.
packages/​http-client-python/​tests/​unit/​test_sse_reconnect_option.py Tests generated runtime variants.
packages/​http-client-python/​tests/​unit/​test_sse_streaming.py Extends serializer coverage.
website/​src/​content/​docs/​docs/​emitters/​clients/​http-client-python/​reference/​emitter.md Documents the emitter option.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .chronus/changes/python-sse-reconnect-option.md
Copy decoder metadata before EOF exit and reconnect decisions in sync and async streams. Cover metadata-only blocks across reconnect options and flavors while preserving enabled resumption and HTTP 204 termination.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 12, 2026 16:02

Copilot AI 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.

🔵 Needs a closer look

The changelog classifies a runtime-breaking default change as a feature.

1 open finding
1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Low severity Classify changed SSE client EOF behavior as a breaking change

.chronus/​changes/​python-sse-reconnect-option.md:2

This changes existing generated SSE clients from reconnecting at EOF to stopping by default, so the output is not semantically equivalent and existing runtime behavior changes. Per website/src/content/docs/docs/handbook/breaking-change-policy.mdx:19-20,79-81 and .chronus/config.yaml:19-32, classify this entry as breaking rather than feature.

🧠 Review effort: Balanced

@l0lawrence
Libba Lawrence (l0lawrence) added this pull request to the merge queue Oct 13, 2026
Merged via the queue into microsoft:main with commit 91cfe96 Oct 13, 2026
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants