Called once when close() closes the stream, before the listeners registered for the
closed event. Only the public close() method invokes it. An internal non-retryable
termination dispatches the error and closed events without it, because the errorFilter
caller already received that error. A server-sent SSE frame named closed reaches only the
addEventListener('closed') listeners. Thus neither can look like a user-initiated close.
Called for a connection-level failure or an HTTP error response. A server-sent SSE frame
named error also reaches this slot, with a MessageEvent payload; only that frame carries
a string data property.
An exception this slot throws does not stop the reconnect that follows. The exception rethrows later, on a separate microtask.
Optional event: ErrorEventOptional Called when a connection is established, with the HTTP response headers in the event.
An exception this slot throws does not stop the read loop from starting. The exception rethrows later, on a separate microtask.
Called when a reconnect is scheduled, with the delay in the event.
An exception this slot throws does not stop the reconnect timer from arming. The exception rethrows later, on a separate microtask.
Readonly readyMirrors the most recent server retry: field, in milliseconds; starts at 1000 before any
retry: field has arrived. A server-directed value is capped at one hour. The retry
strategy owns the actual reconnect timing; this slot only supplies the fallback delay for a
reconnect whose strategy call throws, validated and capped at one hour at that point.
Readonly urlRegisters listener for events of type type. The payload type follows
EventSourceEventMap for the event types this implementation itself dispatches; an SSE
event with a server-chosen name carries a MessageEvent.
Removes the most recent registration of listener for events of type type.
Generated using TypeDoc
A W3C-compliant EventSource (server-sent events) client built on a
fetch()-shaped transport,ReadableStream, andAbortController. Unlike the native browserEventSource, an event source built by this package supports request headers, a custom method with a request body, and a read timeout.Remark
The SSE behavior stays as close as possible to the behavior of the original
launchdarkly-eventsourcepackage: the same event names and shapes, the same retry and backoff timing, and the sametext/event-streamparser algorithm.Remark
The Node-only options (
https,proxy,agent,rejectUnauthorized) do not exist here, becausefetch()has no equivalent for them; a caller that needs transport control injects afetch-shaped function instead.Remark
There is no
onmessageslot. The LaunchDarkly SDKs register their message listeners withaddEventListener('message', ...), so this implementation leaves the slot out on purpose.See
https://html.spec.whatwg.org/multipage/server-sent-events.html