clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.04k stars 235 forks source link

Expo Clerk provider crashes instantly #621

Closed elmarvr closed 1 year ago

elmarvr commented 1 year ago

Clerk instantly crashes without error message. ApiKey: clerk.trusty.dory-86.lcl.dev

SokratisVidros commented 1 year ago

Hi @elmarvr. Can you please share the reproduction steps? Are you trying it via https://github.com/clerkinc/clerk-expo-starter?

BrettCrowley77 commented 1 year ago

Same here. I couldn't get the starter example to work because of dependency conflicts in the package.json. I have the following installed in my environment:

With the following App.js code, the app fails immediately without an error code, but with the warning 'Possible Unhandled Promise Rejection (id: 0).'

import React from 'react'; import {View, Text} from 'react-native'; import {ClerkProvider} from '@clerk/clerk-expo';

export default function App() { return ( <ClerkProvider frontendApi={'clerk.guided.mule-18.lcl.dev'} > < View > < Text >Hello!</ Text> </ View > </ ClerkProvider > ); }

Update: downgrading to version 0.10.14 give the same result but with the following error message: 'Error: ClerkJS: Network error at "https://clerk.guided.mule-18.lcl.dev/v1/environment?_clerk_js_version=4.22.0" - TypeError: Network request failed. Please try again or contact support@clerk.dev'

SokratisVidros commented 1 year ago

Thanks for reporting. We will have a look and get back to you ASAP.

SokratisVidros commented 1 year ago

@BrettCrowley77 Your Frontend API key (https://clerk.guided.mule-18.lcl.dev) seems to point to a deleted Clerk instance. Can you please update it and try again?

BrettCrowley77 commented 1 year ago

@SokratisVidros I deleted the original instance and created a different one (new API key: 'clerk.first.iguana-94.lcl.dev'), but it gives the same result.

SokratisVidros commented 1 year ago

As far as I can see, the 400 you got lacks the HTTP Authorization header. Please make sure that your tokenCache works as expected and sets the "" value by default so that the header is present in the request.

nikosdouvlis commented 1 year ago

Hello everyone, the clerk-expo-starter has been updated to use the correct dependencies. The dependencies broke when React 18.2.0 released because that version wasn't explicitly listed as a peer dependency of react-native. Please pull the latest changes and run npm i again - you might need to delete node_modules first. Let me know if the build issue persist so I can help.

Regarding @BrettCrowley77 case, I couldn't reproduce the issue with the new frontendAPI. Could you please share more details about your test env? Are you using an emulator or a real device? What OS are you running on? Thanks!

BrettCrowley77 commented 1 year ago

Thanks @SokratisVidros and @nikosdouvlis, I've got it working now.

BrettCrowley77 commented 1 year ago

Edit: this appears to be a problem with my particular project. I created a new project (publishable key: pk_test_Y29zbWljLWZlcnJldC00Ni5jbGVyay5hY2NvdW50cy5kZXYk), and everything works fine again.

@SokratisVidros and @nikosdouvlis this issue suddenly appeared again this morning for me. The following code throws 'Possible Unhandled Promise Rejection (id: 0)' as soon as the app loads. I'm running on windows using the Expo tunnel option on an Android emulator, which until this morning was working with no issues. I was using the legacy frontendAPI key until this morning, I switched to the publishableKey to see if it would make a difference but same error.

`import React from "react"; import { Text, View } from "react-native"; import { SafeAreaProvider } from "react-native-safe-area-context"; import { ClerkProvider } from "@clerk/clerk-expo"; import * as SecureStore from "expo-secure-store";

const tokenCache = { getToken(key) { return SecureStore.getItemAsync(key); }, saveToken(key, val) { return SecureStore.setItemAsync(key, val); }, };

export default function App() { return ( <ClerkProvider publishableKey={"pk_test_Y2xlcmsuZmlyc3QuaWd1YW5hLTk0LmxjbC5kZXYk"} tokenCache={tokenCache}

< View > < Text >Hello world! ); }`
SokratisVidros commented 1 year ago

Thanks for the update. We've managed to reproduce this and working on a fix.

SokratisVidros commented 1 year ago

@BrettCrowley77 can you please try again? The issue should be fixed now.

BrettCrowley77 commented 1 year ago

@SokratisVidros it is working again, thanks!