Skip to content

Polyfill DOMException#341

Merged
davidliu merged 1 commit into
mainfrom
dl/domexception_polyfill
Apr 14, 2026
Merged

Polyfill DOMException#341
davidliu merged 1 commit into
mainfrom
dl/domexception_polyfill

Conversation

@davidliu

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-bot Bot commented Apr 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ff85fce

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@davidliu davidliu merged commit 5486644 into main Apr 14, 2026
8 checks passed
@davidliu davidliu deleted the dl/domexception_polyfill branch April 14, 2026 11:41
@github-actions github-actions Bot mentioned this pull request Apr 14, 2026
davidliu pushed a commit that referenced this pull request Apr 21, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @livekit/react-native@2.10.1

### Patch Changes

- Fix metro warning on invalid path configuration in package.json -
[#343](#343)
([@davidliu](https://github.com/davidliu))

- Polyfill for DOMException to handle usage in livekit-client -
[#341](#341)
([@davidliu](https://github.com/davidliu))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@florianpreusner

Copy link
Copy Markdown

Hi @davidliu — quick heads-up: we tested 2.10.1 in an Expo SDK 55 / Hermes app and the original Property 'DOMException' doesn't exist crash from #337 still reproduces. After tracing it, I think this PR's polyfill is wired in one line too late in src/index.tsx. Sharing the diagnosis in case it helps.

Setup

  • @livekit/react-native@2.10.1, @livekit/react-native-webrtc@144.0.0, livekit-client@2.18.6
  • Expo SDK 55, Hermes, iOS dev client (Android also affected)
  • Metro resolves @livekit/react-native via the package's exports.defaultlib/commonjs/index.js

Trace (before fix)

Instrumented console.log at the top of each side-effect-import file in lib/commonjs/ plus livekit-client.umd.js:

[DIAG] MediaRecorderShim    eval; global.DOMException = undefined
[DIAG] livekit-client.umd   eval; global.DOMException = undefined   ← would throw here
[DIAG] DOMException polyfill eval; global.DOMException = undefined  ← never reached in time

MediaRecorderShim is required on line 47 of compiled index.js, before the DOMException polyfill on line 48 (mirroring src/index.tsx lines 3-4). Its transitive chain is:

./polyfills/MediaRecorderShim
  → ../audio/MediaRecorder
    → ../logger              ← does `import { … } from 'livekit-client'`
      → livekit-client       ← top-level `class DeferrableMapAbortError extends DOMException`

So livekit-client evaluates during the require of line 3, before line 4 (the polyfill import) ever runs. The direct livekit-client imports lower in index.tsx (useParticipant, useRoom, LiveKitRoom, etc.) are fine because by the time those re-exports load, the polyfill has run — the issue is the indirect chain through MediaRecorderShim → MediaRecorder → logger.

Verified fix — swap lines 3 and 4

 import 'well-known-symbols/Symbol.asyncIterator/auto';
 import 'well-known-symbols/Symbol.iterator/auto';
-import './polyfills/MediaRecorderShim';
 import './polyfills/DOMException';
+import './polyfills/MediaRecorderShim';

After the swap, the same trace becomes:

[DIAG] DOMException polyfill eval; global.DOMException = undefined → installs polyfill
[DIAG] MediaRecorderShim    eval; global.DOMException = function
[DIAG] livekit-client.umd   eval; global.DOMException = function    ← happy

App boots cleanly, no consumer-side polyfill needed.

Happy to open a PR if helpful — just wanted to flag this since #337 is closed and other users on 2.10.1 will hit the same crash.

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.

registerGlobals() should polyfill DOMException for Hermes

2 participants