question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug report

Describe the bug

Expo apps that use supabase/supabase-js completely break after updating to SDK43.

To Reproduce

  1. Go to https://github.com/10000multiplier/exposupabasebug
  2. git clone https://github.com/10000multiplier/exposupabasebug.git
  3. npm i
  4. expo start

Expected behavior

Supabase-js behaves flawlessly on expo apps as it did on SDK42.

More info

The fatal error that appears after running expo start:

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.

System information

  • OS: Windows
  • Version of supabase-js: ^1.25.2
  • Version of Node.js: 16.13.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
ChronSyncommented, Nov 1, 2021

As an update, it appears that adding detectSessionInUrl: false into the options of createClient resolves this issue. This certainly seems to be a new change compared to last time I tried it in a native context, and I’m not sure if this affects other functionality of using Supabase in Expo.

Example:

export const supabaseClient = createClient(
  my.supabase.url,
  my_supabase_key,
  {
    localStorage: AsyncStorage as any,
    autoRefreshToken: true,
    persistSession: true,
    detectSessionInUrl: false,
  }
);
2reactions
ChronSyncommented, Nov 1, 2021

Of relevance, when running this example, this error shows up as well:

TypeError: undefined is not an object (evaluating 'window.location.href')
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
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.10:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:168062:3 in global code

image

I’ve just tested in one of my in-development projects, and can confirm that the same issue exists. The error shown on screen seems to point towards the getParameterByName function in gotrue-js: https://github.com/supabase/gotrue-js/blob/master/src/lib/helpers.ts#L16

image

Edit - 04:50 UK time: Checked for issues in the main expo repo and haven’t found any reports related to href not being defined. Realistically, window doesn’t exist in React Native, but it doesn’t explain why this issue didn’t exist until recently. This issue doesn’t happen when running on Web, and only happens when running the native app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

expo publish creates broken build and app crash on launch
Actual Behavior. trying to publish the app using expo publish creates a broken build and when i try to access the app through...
Read more >
Troubleshooting build errors and crashes - Expo Documentation
This particular error means that the app is importing ./src/Routes and it is not found. The cause could be that the filename case...
Read more >
React Native Expo App breaks on "There are multiple ...
My react native expo app broke after I changed the casing of the folder, It worked locally but it broke when I connected...
Read more >
5 common errors found in a React Native app (using Expo)
In this article, I will list 5 errors that we as developers faced, while creating a mobile app in React Native (using Expo)...
Read more >
Expo built app crash on Testflight | Apple Developer Forums
This means that your app crashed itself by calling abort . The presence of the Last Exception Backtrace section indicates that this is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found