featurehub_sse_client 1.4.0
featurehub_sse_client: ^1.4.0 copied to clipboard
A Dart-IO based client implementation of Server-Sent Events.
Changelog #
- 1.4.0
- requires Dart SDK 3.10 or later; upgraded dependencies (http ^1.5.0, collection, http_parser, logging)
- removed use of http's private
encodingForCharset, which newer http versions no longer provide EventSourceReadyStatevalues renamed toconnecting,open,closed; the uppercase names remain as deprecated aliases- ready state changes are now logged via
logginginstead ofprint - adopted
package:lintsrecommended rules and fixed all analyzer issues - event stream parsing now follows the WHATWG SSE specification:
- the last event ID persists across events until the server sends a new
idfield, soLast-Event-IDis sent correctly on reconnection (previously any event without anid, or a heartbeat comment, cleared it) - every event's
idis the current last event ID (""if none), rather thannullwhen the block had noidfield - blocks with no
datafield (e.g. heartbeat comments, id-only blocks) are no longer dispatched as empty events - events without an
eventfield have the type"message"rather thannull - invalid
retryvalues are ignored rather than throwing, andidvalues containing NULL are ignored - malformed UTF-8 is replaced rather than throwing, and a leading BOM is ignored
- the decoded stream now propagates errors and completion
- the last event ID persists across events until the server sends a new
- new
EventSource.lastEventIdgetter - the client is now responsible for reconnecting, configured with a new
ReconnectPolicy(reconnectPolicy:onEventSource.connect):- reconnects when the server closes the stream, on network/stream errors, and on retryable statuses
- by default stops on non-retryable statuses (1xx-4xx) and retries 5xx using a separate
serverErrorDelay - configurable
delay,serverErrorDelay,maxAttempts(consecutive, reset on a successful connection),backoffMultiplier,maxDelay,honourServerRetryandshouldRetryStatus;ReconnectPolicy.nonedisables it - defaults: 3s delay (or the server's
retry:value), 30s after a 5xx, unlimited attempts, no backoff (previously the delay doubled on every failed attempt, forever) - each scheduled reconnection is delivered to listeners as an
EventSourceReconnectevent (type"reconnect"), also available asEventSource.onReconnect - when the policy gives up, the final
EventSourceSubscriptionExceptionis added to the stream as an error and the ready state becomesclosed; the ready state is nowconnecting(notclosed) while waiting to reconnect
- new
EventSource.close(), which also cancels a pending reconnection EventSourceSubscriptionException.statusCodeis now the real HTTP status (non-200 responses were previously reported as500), and0when no HTTP response was received (network errors, dropped connections); seeisHttpError- the ready state controller no longer receives the same state twice in a row
- if the first connection is made by a listener (
openOnlyOnFirstListener), failures follow the reconnect policy rather than raising an unhandled error;connect()andreopen()still throw if their connection attempt fails
- 1.3.3
- bumped http package from ^0.13.0 to ^1.1.0 and SDK version to < 3.9.9
- upgrades for major functionality in 1.5.9
- 1.3.2 - print statement leakages
- 1.3.1 - bug fix around the closing of the connection and support for notification of status of event stream, and reopening
- 1.3.0 - repository url change and formatting updates
- 1.2.0 - null save version
- 1.0.0 - this is the fork and re-release of the eventsource package