Add TextDecoder fallback when fatal is unsupported - #2037
Conversation
🦋 Changeset detectedLatest commit: a48e60c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Thanks @xianshijing-lk ! I addressed the comment by Devin before I saw your comment. Happy to revert those changes if they are unwanted, though they make sense to me. |
|
@JoelTowell Good catch here! I think this can be even simpler - you probably can just remove |
Thanks @1egoman! I reverted my changes and just stopped passing |
|
Yep I think it should be fine in practice. Thanks for the contribution! |
Summary
TextStreamReadercurrently constructsTextDecoder('utf-8', { fatal: true })unconditionally. I ran into an issue with React Native whereTextDecoderis present, but constructing it withfatal: truethrows:As a result, text stream handling fails before any decoding happens. This may not be isolated to one environment, as Expo explicitly notes that "[t]he
TextDecoderAPI is not spec-compliant on native platforms".The LiveKit React Native SDK uses a polyfill for
TextDecoder(1, 2), but this will only take effect ifTextDecoderis not already defined.Based on discussion, change has been simplified from fallback to omitting the offending option.
Changes
fatal: truewhen constructingTextDecoderinTextStreamReaderandbytesToDecodedUtf8function