noob saibot
noob saibot5mo ago

Convex + Clerk crashing in react-native after using the new Convex Auth

Hi Convex team, I have 2 applications: 1 react-native-expo app using convex.dev (+ clerk for authentication). This app has been happily working fine for the past 4 months. 1 nextjs app (app router). For the nextjs app, I have decided to use the new Convex Auth library. So I followed the official documentation here https://labs.convex.dev/auth. I have successfully setup the new convex auth in dev and in production. And everything works fine in the web. Here is now my auth config with the 2 entries: the first entry is used with clerk (this is how I started my application). The second entry is the new convex auth:
export default {
providers: [
{
domain: process.env.CONVEX_AUTH_PROVIDER_DOMAIN,// <-- for clerk
applicationID: "convex",
},
{
domain: process.env.CONVEX_SITE_URL, // <-- for convex auth
applicationID: "convex",
},
],
};
export default {
providers: [
{
domain: process.env.CONVEX_AUTH_PROVIDER_DOMAIN,// <-- for clerk
applicationID: "convex",
},
{
domain: process.env.CONVEX_SITE_URL, // <-- for convex auth
applicationID: "convex",
},
],
};
This morning, I decided to spin up my react native expo (using same convex backend). I'm observing that clerk is crashing at start. I'm not saying whether the crash is caused by this new setup (I have already filed an issue in the clerk forum). But I'm just investigating whether the crash could be related to the my new setup. Also I am hesitating to rollback my changes given that new tables related to authentication have already been created (in dev and in prod). Can I safely rollback my changes (and see if it fixed my issues?) Thank you for your support.
5 Replies
ian
ian5mo ago
It's always safer to experiment in dev than prod (assuming you have users). but yes it's ok to deploy a schema that doesn't list all the tables that are actually existing - it won't delete data. When you later deploy with the auth tables again, it will validate that all the documents in the DB match the schema you're deploying. If you made schema changes that are not backwards compatible then deploying the old schema might not work - e.g. you might have to change some field to optional if you deprecated/removed one, or add an optional field for a field that you had added. https://search.convex.dev/?q=migration has some good Stack articles on migrations
Convex Developer Search
Search Docs, Stack, Discord all at once
Michal Srb
Michal Srb5mo ago
I'm observing that clerk is crashing at start.
What exactly are you observing? Do you have an error message?
noob saibot
noob saibotOP5mo ago
When app is starting, it crashes with below error:
TypeError: Cannot read property 'useMemo' of null

This error is located at:
in ConvexProviderWithClerk (created by ConvexProvider)
in ConvexProvider (created by RootProviders)
in SWRConfig (created by OrganizationProvider)
in OrganizationProvider (created by ClerkContextProvider)
in ClerkContextProvider (created by ClerkProviderBase)
in ClerkProviderBase (created by ClerkProvider)
in ClerkProvider (created by ClerkProvider)
TypeError: Cannot read property 'useMemo' of null

This error is located at:
in ConvexProviderWithClerk (created by ConvexProvider)
in ConvexProvider (created by RootProviders)
in SWRConfig (created by OrganizationProvider)
in OrganizationProvider (created by ClerkContextProvider)
in ClerkContextProvider (created by ClerkProviderBase)
in ClerkProviderBase (created by ClerkProvider)
in ClerkProvider (created by ClerkProvider)
It is worth noting that seems to occur only on android (my app is a react-native + expo app). I haven't observed it yet on ios.
Michal Srb
Michal Srb5mo ago
Hmm, that's really weird. That suggests React itself is somehow null. The cjs version has this code:
var import_react2 = require("react");
// later...
import_react2.useMemo
var import_react2 = require("react");
// later...
import_react2.useMemo
noob saibot
noob saibotOP5mo ago
Hi @Michal Srb I reverted the app a few early commits back where everything was working and rewrote the app from there. I believe something went wrong with some dependencies and they messed up convex (??).

Did you find this page helpful?