player icon indicating copy to clipboard operation
player copied to clipboard

onError does not work

Open ablackoff opened this issue 7 months ago • 2 comments

Current Behavior:

When using the @vidstack/react player and passing src as an object:

src={{
  src: "https://test.com/video",
  type: "video/mp4",
}}

if the link points to a non-existent file (e.g., returns 404 or another loading error), the player does not trigger the onError callback. Visually, the player behaves as if the video was loaded successfully, which is misleading — in reality, the file is not available.

Passing src as a plain string (without the object) is not viable in this case, because the files are coming from S3 without MIME type information.

Upon investigation, this issue appears to have been introduced by the following commit: MR

It seems that after this change, the error handling behavior broke.

Expected Behavior:

If the video URL is invalid (e.g., unreachable or returns an error), the onError callback should:

  • Be triggered correctly
  • Provide meaningful error information (e.g., HTTP status code or message)

This is essential for proper error handling in the app and for displaying a fallback UI.

Steps To Reproduce:

  1. Use @vidstack/react
  2. Pass src as an object with an unreachable URL
  3. Add an onError handler
  4. Observe that the handler is not called

Reproduction Link: https://stackblitz.com/edit/vidstack-examples-f8k9ofuk?file=src%2Fplayer.tsx

Environment:

Example:

  • Framework: React 19
  • Meta Framework: Next.js 15
  • Node: 20+

ablackoff avatar Jun 09 '25 13:06 ablackoff

I’ve investigated the issue, and here’s what I found:

The onError callback does work as expected when the URL returns an actual error response, such as a 404 Not Found. In your example (https://test.com/video), the URL doesn’t return any response at all

It simply hangs without sending back a status. In such cases, the browser keeps waiting for a response, and this is not treated as an error by the player or the underlying

I tested with a URL like https://test.io/video, which returns a 404, and confirmed that onError is called and provides the expected error event.

chemsabd avatar Jun 23 '25 13:06 chemsabd

@chemsabd If you look at the example I attached and add https://test.io/video, the console doesn’t show any errors indicating that the video isn’t working.

It’s possible that in your case, an older version is being used, and it is functioning correctly.

Image

ablackoff avatar Jun 23 '25 15:06 ablackoff