Skip to main content
The SDK distinguishes between two classes of failures:
  1. Initial sync failures - surfaced as NexusInitError from provideNexus(). With await provideNexus(...), the rejection prevents app.mount() from running.
  2. Background sync / SSE failures - never thrown. They are logged via NexusLogger.error(...), and the existing cache continues to be served.

Error hierarchy

All SDK errors extend NexusError. A single instanceof check covers everything:
The full hierarchy:

When each is thrown

Composables vs imperative - non-throwing vs throwing

Why? Vue components re-evaluate computeds on every reactive change. If useSecret threw on a public key, every render would throw, breaking the component tree.

Handling NexusInitError

provideNexus(app, config) rejects on init failure. The simplest pattern is to catch at the main.ts level:
If you prefer to crash the app entirely (the default behaviour for misconfiguration), just don’t catch - app.mount('#app') won’t be called.

What is NOT thrown

  • Background syncs - silently retried on the next TTL tick. Cache served.
  • SSE transport errors - the SDK reconnects with exponential backoff, then falls back to TTL polling after 3 consecutive failures. No exception surfaces.
  • 304 Not Modified - treated as success; TTL reset.
  • Composable reads for missing/inaccessible keys - return undefined (or the defaultValue for useFlag).

SSE-specific behaviour

SSE failures never propagate to your code. Use useNexusStreamStatus() to detect “live updates are no longer available”:

5xx exponential backoff

When the server returns a 5xx status on /sync, the SDK does not fail silently until the next TTL tick. Instead it:
  1. Catches the response internally and surfaces it as a NexusServerError(status, bodySnippet).
  2. Increments an internal attempt counter and schedules a retry via setTimeout with exponential backoff:
  3. Emits FALLBACK_REASON_TRANSPORT on the stream observer during the wait.
  4. On the next successful sync - including the auto-retry succeeding - resets the counter.