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

added null check to window #153

Merged
merged 4 commits into from
Nov 8, 2021
Merged

Conversation

adtjha
Copy link
Contributor

@adtjha adtjha commented Nov 1, 2021

What kind of change does this PR introduce?

Original
if (!url) url = window.location.href

Added null checks to window,
if (!url) url = window.location && window.location.href || ""

What is the current behavior?

Bug : TypeError: undefined is not an object (evaluating 'window.location.href')

react-native : 0.64.2,
expo : ~43.0.0,
@supabase/supabase-js : ^1.25.2,

TypeError: undefined is not an object (evaluating 'window.location.href')
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:204:6 in guardedLoadModule
at http://192.168.1.37:19000/index.bundle?platform=android&dev=true&hot=false&minify=false:237331:3 in global code

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

What is the new behavior?

No more TypeError, works perfectly fine.

@kiwicopple
Copy link
Member

@adtjha could you please merge the latest changes from master, resolve any conflicts, and then run npm run format? Otherwise this looks good!

FYI, I think this should work too: window?.location?.href || ''

@kiwicopple
Copy link
Member

fixes supabase/supabase#3790

@kiwicopple kiwicopple merged commit a269d81 into supabase:master Nov 8, 2021
@Seanmclem
Copy link

Seanmclem commented Nov 10, 2021

I see this is merged, but I'm still facing this issue with @supabase/supabase-js 1.27.0. How can I make sure I get the fix? ... Temporarily made the fix in my node modules directory. But it seems like supabase needs updated to the latest gotrue-js version? I'd make the PR myself, but I can't find where the version number changes

@github-actions
Copy link
Contributor

🎉 This PR is included in version 1.21.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants