Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'split' of null when using with react native while initializing default session #2674

Closed
harryy2510 opened this issue Jun 8, 2023 · 2 comments
Labels
Bug Something isn't working

Comments

@harryy2510
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

The project is based on react native and utilises amazon-chime-sdk-js and @aws-sdk/client-chime-sdk-messaging for chat. While initializing default session on react native,amazon-chime-sdk-js throws error Cannot read property 'split' of null when it tried to find major version of browser.

Here is the diff that solved my problem:

diff --git a/node_modules/amazon-chime-sdk-js/build/browserbehavior/DefaultBrowserBehavior.js b/node_modules/amazon-chime-sdk-js/build/browserbehavior/DefaultBrowserBehavior.js
index 43cc745..6691c21 100644
--- a/node_modules/amazon-chime-sdk-js/build/browserbehavior/DefaultBrowserBehavior.js
+++ b/node_modules/amazon-chime-sdk-js/build/browserbehavior/DefaultBrowserBehavior.js
@@ -61,7 +61,7 @@ class DefaultBrowserBehavior {
         this.webkitBrowsers = ['crios', 'fxios', 'safari', 'ios', 'ios-webview', 'edge-ios'];
     }
     version() {
-        return this.browser.version;
+        return this.browser.version || "";
     }
     majorVersion() {
         return parseInt(this.version().split('.')[0]);

This issue body was partially generated by patch-package.

@xuesichao
Copy link
Contributor

Hi @harryy2510 , we are using detect() API of detect-browser library to retrieve the browser info in DefaultBrwoserBehavior.js. It seems for react native, the browser info from detect() does not contain a valid value for version, and in this cause your fix serves as a safe guard.

I just checked the implementation of detect-browser and confirm it returns null for version. https://github.com/DamonOehlman/detect-browser/pull/137/files

I'll add your fix to our library. Thanks for sharing this with us!

@xuesichao xuesichao added the Bug Something isn't working label Jun 21, 2023
@xuesichao
Copy link
Contributor

Duplicate of #1856 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants