Skip to content

FCE-2808: Fix module resolution#477

Merged
MiloszFilimowski merged 5 commits intomainfrom
mfilimowski/fce-2808-fix-rn-issues
Feb 17, 2026
Merged

FCE-2808: Fix module resolution#477
MiloszFilimowski merged 5 commits intomainfrom
mfilimowski/fce-2808-fix-rn-issues

Conversation

@MiloszFilimowski
Copy link
Collaborator

@MiloszFilimowski MiloszFilimowski commented Feb 17, 2026

Description

  • Added fast-text-encoding for bare react-native projects. Expo has TextEncoder included. This library should skip the polyfill if TextEncoder is available globally.

  • Removed redundant changes in the package.json

  • Changed how resolveFishjamUrl works. In bare react-native the polyfill works differently and won’t throw an error here. The new approach should work both on web and mobile.

  • Changed livestream.ts to import WHEP and WHIP clients dynamically. Internally WHEPClient extends EventTarget globally (it’s a class) which conflicts with the react-native polyfill. By importing them dynamically at a later stage the polyfill should work as expected.

  • Documentation needs to be updated on transcient deps for bare RN projects and pre Expo SDK 54.

Motivation and Context

  • The mobile SDK was not linked properly.
  • The mobile SDK didn't work for bare projects.

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 17, 2026

@MiloszFilimowski MiloszFilimowski changed the title fix module resolution FCE-2808: Fix module resolution Feb 17, 2026
@MiloszFilimowski MiloszFilimowski marked this pull request as ready for review February 17, 2026 16:11
@MiloszFilimowski MiloszFilimowski marked this pull request as draft February 17, 2026 16:12
@MiloszFilimowski MiloszFilimowski marked this pull request as ready for review February 17, 2026 16:41
@MiloszFilimowski MiloszFilimowski merged commit 4bb1444 into main Feb 17, 2026
2 checks passed
@MiloszFilimowski MiloszFilimowski deleted the mfilimowski/fce-2808-fix-rn-issues branch February 17, 2026 16:41
@MiloszFilimowski MiloszFilimowski restored the mfilimowski/fce-2808-fix-rn-issues branch February 17, 2026 16:44
@MiloszFilimowski MiloszFilimowski requested review from Copilot and removed request for Copilot February 17, 2026 16:44
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

Fixes React Native (bare) module resolution and runtime polyfill conflicts for the Fishjam mobile SDK, while keeping web behavior working.

Changes:

  • Add fast-text-encoding polyfill to the mobile WebRTC polyfill setup.
  • Update resolveFishjamUrl to avoid relying on URL-constructor throwing behavior across platforms.
  • Switch WHIP/WHEP client imports in livestream.ts to dynamic imports to avoid EventTarget polyfill conflicts.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
yarn.lock Locks fast-text-encoding and adjusts dependency resolutions for RN support.
packages/ts-client/src/livestream.ts Uses dynamic imports for WHIP/WHEP clients to avoid RN EventTarget conflicts.
packages/react-client/src/utils/fishjamUrl.ts Changes Fishjam ID → URL resolution logic to be RN-safe.
packages/mobile-client/src/webrtc-polyfill.ts Adds fast-text-encoding side-effect import before WebRTC globals registration.
packages/mobile-client/package.json Adjusts entrypoints and dependency/peerDependency declarations for RN module resolution.

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

Comment on lines +28 to 29
const { WHEPClient } = await import('@binbat/whip-whep/whep');
const whep = new WHEPClient();
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The new dynamic import can now fail at runtime (e.g. bundler/module resolution issues) and will reject with the raw import error rather than a LivestreamError. To keep the public error surface consistent, wrap the import in try/catch and map failures to LivestreamError.UNKNOWN_ERROR (or reject accordingly).

Copilot uses AI. Check for mistakes.
Comment on lines 32 to 38
"peerDependencies": {
"@fishjam-cloud/react-native-webrtc": "0.25.0",
"expo": "*",
"react": "*",
"react-native": "*"
"react-native": "*",
"react-native-get-random-values": "1.11.0"
},
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

@fishjam-cloud/react-native-webrtc and react-native-get-random-values are listed in both dependencies and peerDependencies. A dependency does not satisfy a peer dependency, so consumers may still see unmet-peer warnings and can end up with duplicate installs. Consider choosing one model (peer-only for host-provided native deps, or dependency-only for auto-install), and if keeping them as peers, remove them from dependencies and/or mark them optional via peerDependenciesMeta.

Copilot uses AI. Check for mistakes.
const { WHEPClient } = await import('@binbat/whip-whep/whep');
const whep = new WHEPClient();

return new Promise<ReceiveLivestreamResult>((resolve, reject) => {
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Inside this new Promise(...) block, the whep.view(...).catch(...) logic only rejects when the caught value is an Error. If the underlying client rejects with a non-Error value, the promise can remain pending indefinitely. Consider ensuring the catch path always rejects (defaulting to LivestreamError.UNKNOWN_ERROR).

Copilot uses AI. Check for mistakes.
export function resolveFishjamUrl(fishjamId: string): string {
try {
if (/^https?:\/\//.test(fishjamId)) {
return new URL(fishjamId).href;
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

resolveFishjamUrl can still throw if fishjamId starts with http(s):// but is not a valid absolute URL (e.g. malformed input). Previously this was caught and fell back to the default connect URL; consider keeping a try/catch (or using URL.canParse where available) around new URL(...) so the function never throws for invalid inputs.

Suggested change
return new URL(fishjamId).href;
try {
return new URL(fishjamId).href;
} catch {
// Fall back to default connect URL if the provided string is not a valid absolute URL.
return `https://fishjam.io/api/v1/connect/${fishjamId}`;
}

Copilot uses AI. Check for mistakes.
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.

2 participants

Comments