TrackID is undefined during auto publishing of microphone track (audio={true}) in LiveKitRoom (React Native SDK)
I’m encountering an issue in the React Native SDK (@livekit/react-native) where auto-publishing of the microphone track sometimes results in a missing track ID. When using the LiveKitRoom component with audio set to true, the SDK automatically handles microphone publishing. However, during this process, the published track sometimes shows trackID as undefined, leading to a runtime error: “TypeError: Cannot read property 'toLowerCase' of undefined” Which seems to come from internal SDK code, where toLowerCase() is called on trackID, assuming it is a string. My setup involves the @livekit/react-native SDK (latest version) running on both Android and iOS platforms. I’m using the LiveKitRoom component in this way: TSX
<LiveKitRoom
serverUrl="wss://your-livekit-server-url.livekit.cloud"
token={token}
connect={true}
audio={true}
video={false}
/>
I’m not manually creating or publishing any tracks—the SDK is responsible for auto-publishing the microphone track. However, the SDK sometimes publishes a track object like this:
json
{
"enabled": true,
"kind": "audio",
"muted": false,
"pID": "PA_dVTQPxudDipR",
"participant": "qOFJJ4pRNCMHEox2MrN7Gc5PlMO2",
"room": "room_qOFJJ4pRNCMHEox2MrN7Gc5PlMO2",
"source": "microphone",
"streamID": "8297a9c7-3d83-4d40-8301-baa46c419a45",
"streamTrackID": "8297a9c7-3d83-4d40-8301-baa46c419a45",
"trackID": undefined
}
Shortly after, I received this error in the logs:
javascript
**TypeError: Cannot read property 'toLowerCase' of undefined**
I expect the SDK to assign a valid string trackID to any auto-published microphone track and to handle cases where trackID might be missing before calling any string methods on it. Since track control is fully managed inside the SDK and not exposed in the React Native version, I believe this is an internal SDK bug. Please let me know if this is a known issue, whether there’s a temporary workaround, or if sharing a minimal reproduction repo would help in diagnosing the problem. Thank you for your work on LiveKit—I look forward to your guidance.
I'm encountering the same issue
Same here!
same issue, any update @davidliu
Hmm, we don't call toLowerCase() on trackId anywhere in this library or in livekit-client. Is there some more logs indicating which line of code it's coming from?
It sorta sounds similar to issue #222, but really need some more information. It'd be great if you could include a repro, as I don't see it on my end.
what worked for me, check that this is present in index.js
const { registerGlobals } = require('@livekit/react-native');
registerGlobals();
make sure that registerGlobals is imported from this library and not react-native-webrtc
I have the exact same issue with android, solution offered by @15rock-naman-gupta isnt working in my case. enabling audio for livekit in android still uresolved.
"publishing track"{ "room":"call-1765653122252", "roomID":"RM_GUKjuNJoK59r", "participant":"aa55f9f0-578a-11f0-b526-11be3533b15c", "pID":"PA_uPCD7YduXKfe", "trackID":"undefined", "source":"microphone", "muted":false, "enabled":true, "kind":"audio", "streamID":"FA5083EB-4404-46D0-9666-01A46634E226", "…" }
"trackID":"undefined",
@davidliu "@livekit/react-native": "^2.9.4", "@livekit/react-native-webrtc": "^137.0.2", "livekit-client": "^2.15.15", "react-native": "^0.81.0",
@AbdulRehman960 this log is emitted before the track is actually published, and before a trackId is assigned from the server. trackId being undefined here is expected.
Closing as dupe of https://github.com/livekit/client-sdk-js/issues/1433
Please ensure that you call registerGlobals() from the @livekit/react-native package, as shown in our usage instructions.