Skip to content

FCE-2802: DOMExeption when Android permissions missing#480

Merged
MiloszFilimowski merged 3 commits intomainfrom
mfilimowski/fce-2802-domexeption
Feb 23, 2026
Merged

FCE-2802: DOMExeption when Android permissions missing#480
MiloszFilimowski merged 3 commits intomainfrom
mfilimowski/fce-2802-domexeption

Conversation

@MiloszFilimowski
Copy link
Collaborator

Description

Replace instanceof DOMException with instanceof Error in react-client error handling for getUserMedia errors.

DOMException is a browser-only API unavailable in React Native, so these checks always failed on mobile — all media errors were silently classified as UNHANDLED_ERROR. A DOMException polyfill wouldn't help either, since RN WebRTC errors aren't instances of the polyfilled class.

Since DOMException extends Error in browsers, switching to instanceof Error preserves existing behavior on web while fixing error classification on mobile.

Motivation and Context

Media error handling was broken on mobile due to reliance on a browser-specific global.

Documentation impact

  • Documentation update required
  • Documentation updated in another PR
  • No documentation update required

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)

@linear
Copy link

linear bot commented Feb 23, 2026

@MiloszFilimowski MiloszFilimowski changed the title add DOMException polyfill FCE-2802: DOMExeption when Android permissions missing Feb 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes React Native media error handling by replacing instanceof DOMException checks with instanceof Error checks. Since DOMException is a browser-only API unavailable in React Native, all media errors were previously misclassified as UNHANDLED_ERROR on mobile. The change preserves browser behavior (where DOMException extends Error) while enabling proper error classification on React Native (where WebRTC errors are regular Error objects).

Changes:

  • Replace instanceof DOMException with instanceof Error in media error handling logic
  • Affects three error check locations across two files handling getUserMedia errors

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/react-client/src/utils/errors.ts Updated error type check in parseUserMediaError function
packages/react-client/src/devices/mediaInitializer.ts Updated error type checks in getSingleMedia and getAvailableMedia functions
Comments suppressed due to low confidence (1)

packages/react-client/src/utils/errors.ts:13

  • The PR title says "add DOMException polyfill" but the actual change removes the dependency on DOMException by using Error instead. Consider updating the PR title to accurately reflect the change, such as "Replace DOMException with Error for React Native compatibility" or similar.
  if (!(error instanceof Error)) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 29 to 30
if (!(err instanceof Error)) return [null, UNHANDLED_ERROR];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: isn't that condition meaningless? why are we checking against a base Error class? wouldn't it be better to just return [null, errorMap[err.name] ?? UNHANDLED_ERROR]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

packages/react-client/src/utils/errors.ts:13

  • The PR description mentions "switching to instanceof Error" but the code uses type assertion (error as Error).name instead of actually checking with instanceof Error.

The type assertion provides no runtime safety, unlike the instanceof check mentioned in the PR description. This is inconsistent with the stated approach and with error handling patterns elsewhere in the codebase (see useDataChannel.ts for examples of proper instanceof Error checks).

  switch ((error as Error).name) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MiloszFilimowski MiloszFilimowski merged commit 1fc7be9 into main Feb 23, 2026
6 checks passed
@MiloszFilimowski MiloszFilimowski deleted the mfilimowski/fce-2802-domexeption branch February 23, 2026 16:53
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.

3 participants