Description
livekit-client v2.18.1 crashes at module load time in React Native (Hermes engine) with:
ERROR [ReferenceError: Property 'DOMException' doesn't exist]
Root Cause
PR #1820 ("Data track integration") added class DeferrableMapAbortError extends DOMException in src/utils/deferrable-map.ts. Since DOMException is not exposed as a global in React Native's Hermes engine, this extends clause fails at class evaluation time, preventing the entire SDK from loading.
There are also other DOMException references (e.g. new DOMException(...) in WebSocketStream.ts and abort-signal-polyfill.ts) that would fail at call time on affected code paths.
Environment
livekit-client: 2.18.1
@livekit/react-native: 2.10.0
- React Native with Hermes engine (Expo)
Workaround
Adding a DOMException polyfill before any livekit imports:
if (typeof globalThis.DOMException === "undefined") {
class DOMException extends Error {
code: number;
constructor(message?: string, name?: string) {
super(message);
this.name = name ?? "Error";
this.code = 0;
}
}
globalThis.DOMException = DOMException;
}
Suggested Fix
@livekit/react-native already polyfills WritableStream, ReadableStream, and crypto.randomUUID for React Native compatibility. A DOMException polyfill should be added there as well. Alternatively, the SDK could avoid extending DOMException directly to maintain compatibility with environments where it's not available.
Description
livekit-clientv2.18.1 crashes at module load time in React Native (Hermes engine) with:Root Cause
PR #1820 ("Data track integration") added
class DeferrableMapAbortError extends DOMExceptioninsrc/utils/deferrable-map.ts. SinceDOMExceptionis not exposed as a global in React Native's Hermes engine, thisextendsclause fails at class evaluation time, preventing the entire SDK from loading.There are also other
DOMExceptionreferences (e.g.new DOMException(...)inWebSocketStream.tsandabort-signal-polyfill.ts) that would fail at call time on affected code paths.Environment
livekit-client: 2.18.1@livekit/react-native: 2.10.0Workaround
Adding a
DOMExceptionpolyfill before any livekit imports:Suggested Fix
@livekit/react-nativealready polyfillsWritableStream,ReadableStream, andcrypto.randomUUIDfor React Native compatibility. ADOMExceptionpolyfill should be added there as well. Alternatively, the SDK could avoid extendingDOMExceptiondirectly to maintain compatibility with environments where it's not available.