Skip to content

Fix AbortError when playing tweet videos under Strict Mode - #224

Open
ShobhanKarthish wants to merge 1 commit into
vercel:mainfrom
ShobhanKarthish:fix/react-tweet-video-aborterror
Open

Fix AbortError when playing tweet videos under Strict Mode#224
ShobhanKarthish wants to merge 1 commit into
vercel:mainfrom
ShobhanKarthish:fix/react-tweet-video-aborterror

Conversation

@ShobhanKarthish

Copy link
Copy Markdown

Summary

Playing a tweet video in React Strict Mode (dev) can log:

AbortError: The play() request was interrupted because the media was removed from the document.

The play button handler was grabbing the video via previousSibling, then calling setPlayButton(false). That unmounts the button and can leave play() racing a remount, which surfaces as an AbortError even though playback often still works on retry.

This change:

  • Adds a videoRef on the <video> element and uses that instead of previousSibling
  • Ignores AbortError in the .catch so expected interruptions from remounts don’t spam the console

Test plan

  • Embed a video tweet (e.g. id 2006254902629044564) with React Strict Mode on
  • Click play and confirm the video starts without an AbortError in the console
  • Confirm controls / focus still work after play
  • Confirm real play failures still log and restore the play button

Closes #213

Keep a stable videoRef instead of reading previousSibling after the
play button unmounts, and ignore AbortError from interrupted play().
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@ShobhanKarthish is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AbortError when playing video: "media was removed from the document"

1 participant