microsoft / microsoft/typespec

[http-client-python] Add SSE reconnection

Open
#11,761 2 comments 1 reaction 1 assignee Claimed by @l0lawrence View on GitHub
emitter:client:python feature
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

Structured SSE streams generated by `@typespec/http-client-python` parse and expose `stream.last_event_id` and `stream.retry`, and operations accept `last_event_id=` to send `Last-Event-ID` for manual resume. They intentionally do not automatically reconnect after an unexpected EOF.

Add automatic SSE reconnection once the behavior is available in the azure-core streaming/transport layer rather than implementing a generator-vendored reconnect loop. The integration should:

- Reconnect after unexpected EOF using the SSE default delay, overridden by valid `retry:` fields.
- Send the latest event ID through `Last-Event-ID`.
- Stop reconnecting after terminal events and HTTP 204 responses.
- Preserve normal 301/307 redirect handling through the pipeline.
- Support sync and async streams.
- Fix the `Streaming_Sse_Protocol_reconnect` Spector scenario.

Related Spector coverage issue: #11572.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.