Skip to main content
The /movie and /tv endpoints stream via SSE — error handling looks different from a standard JSON API. This page covers every failure mode and the recommended pattern for each.
These error handling examples connect to your self-hosted Vyla API instance. Replace http://localhost:7860 with your actual API URL when deploying to production.

Error Response Shape

Non-streaming endpoints (/health, /subtitles, /downloads, /test) return standard JSON errors:
For /movie and /tv, HTTP 200 is returned immediately when the SSE stream opens. Failures surface as zero source events followed by a done event with total: 0 — not as HTTP error codes.

Handling No Sources

The most common failure — all providers failed to return a playable stream. Detect it by checking total in the done event.

Source Fallback Queue

Sources stream in as providers resolve. Queue every source event URL and fall back to the next one if playback fails mid-stream:

Network Timeouts

The SSE stream can stay open 20+ seconds while slow providers resolve. Set a client-side timeout using AbortController:

Handling Missing Subtitles

Subtitles arrive in the meta event. Always guard against an empty array:

Retry Logic for Stream Failures

Add a top-level retry for complete stream failures (network errors, server 5xx before the stream opens):

Checking Health Before Requests

If you’re building a dashboard, check provider health before opening a stream to give users an early warning:

Full Error Boundary (React)