Core
withSSEOnInvalidEvent
Observes SSE events that have no matching event struct or fail validation.
@defjs/core · Function
Signature
function withSSEOnInvalidEvent( handler: ClientSSEOptions["onInvalidEvent"], ): ClientOption;
The handler may be async and is awaited. The callback receives:
{
reason: 'missing-struct' | 'validation-failed'
message: { id: string; event: string; data: string }
cause?: unknown
signal: AbortSignal
}- The invalid event is always dropped; it is never delivered to the stream. The callback only observes it.
- The return value is ignored. An error thrown by the callback is swallowed and does not close the stream, unless
signalhas already aborted. causeis set forvalidation-failed. Without a handler the invalid event is dropped silently.
Parameters
Prop
Type
handler ClientSSEOptions["onInvalidEvent"]Observer callback for invalid events.
Returns
An option that sets config.sse.onInvalidEvent.