Defjs
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 signal has already aborted.
  • cause is set for validation-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.

Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao