#useQuery could not be found in production

1 messages · Page 1 of 1 (latest)

robust knoll
#

i use react native exp[o for the front and django for backend
convex is to handle real time data
i keep getting this error only in production after OTA update push
even if the update was not related to convex
then i must rebuild the whole app to refresh this
and it keeps happening
when checking the code
the only type error i have is "type instantiation is excessively deep and can possibly infinite"
but this shouldnt cause this issue
when running convex dev / convex deploy there is no errors or issues.

unkempt ravenBOT
#

Hi @robust knoll. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information in the knowledge sources, your issue with useQuery not being found in production after an OTA (Over-The-Air) update in a React Native Expo app is not directly documented, but there are several related discussions and possible causes:

  1. TypeScript "Type instantiation is excessively deep and possibly infinite" error:
    This error is commonly caused by circular type inference, often due to returning the result of ctx.runQuery, ctx.runMutation, or ctx.runAction directly from another Convex function, or by using Convex-generated types (like Doc) in your function return types. Even if your app builds and deploys without errors, these type issues can cause subtle runtime problems, especially in production or after updates. The recommended fix is to avoid returning Convex-generated types directly and instead return plain objects or explicitly type only the properties you need. See more: Dealing with circular type inference and related Discord threads where this error led to unexpected behavior in production environments<source><https://discord.com/channels/1019350475847499849/1396986143190286499</source>.>
#
  1. OTA Updates and Convex Client Issues:
    There are reports that after OTA updates, especially in Expo/React Native, Convex hooks like useQuery can break or not be found, requiring a full rebuild to resolve. This may be due to mismatches between the JavaScript bundle and the native code, or issues with how Convex is initialized or cached in the app. While not explicitly documented as a Convex bug, similar issues have been discussed, and a full rebuild is often the only reliable fix. Keeping all dependencies (Expo, Convex, convex-helpers, etc.) up to date is important, as some issues have been resolved by updating packages or rebuilding after SDK upgrades<source><https://discord.com/channels/1019350475847499849/1368973828839047198</source>.>

  2. ConvexProvider and React Context:
    If you see errors like "Could not find Convex client! useQuerymust be used in the React component tree underConvexProvider", ensure that your app is correctly wrapped with ConvexProviderand that there are no mismatches in React context between different bundles or after updates. In monorepo or multi-package setups, defining hooks likeuseQueryWithStatus` in the frontend app (not shared backend code) is necessary to avoid context issues<source><https://discord.com/channels/1019350475847499849/1354787990001553438</source>.>

  3. Expo/React Native Specific Issues:
    There have been production-only issues with Convex queries re-running or breaking after navigation or updates, especially with certain Expo SDK versions or when using new architecture features. Sometimes, simply updating all Expo and related packages, or toggling new architecture settings, resolves the issue<source><https://discord.com/channels/1019350475847499849/1368973828839047198</source>.>

#

Summary of Recommendations:

  • Review your Convex function return types and avoid returning Convex-generated types directly.
  • Ensure your app is always wrapped in ConvexProvider.
  • After OTA updates, if issues persist, a full rebuild is often necessary.
  • Keep all dependencies up to date and check for any breaking changes in Expo or Convex.
  • If you are using a monorepo, define frontend hooks in the app package, not shared backend code.

If these steps do not resolve your issue, the knowledge sources do not provide a more specific solution for your exact scenario. If possible, provide more details or error logs for further troubleshooting.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@robust knoll Kapa.ai is still learning and improving, please let me know how I did by reacting below.

robust knoll
#

<@&1228088700710293556>
on development build all works well no issues , when rebuilding it works but when i OTA anything this happens
elaborate more on 2
is there a way to avoid this?

robust knoll
#

@unkempt raven
on development build all works well no issues , when rebuilding it works but when i OTA anything this happens
elaborate more on 2
is there a way to avoid this?

unkempt ravenBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

Certainly! Here’s a more detailed explanation of point 2 regarding OTA (Over-The-Air) updates and Convex client issues in Expo/React Native:

When you push an OTA update with Expo, only the JavaScript bundle is updated on users’ devices. Native code and any native modules remain unchanged. If your update changes how Convex is initialized, how hooks are imported, or if there are mismatches between the JS bundle and the native code (or cached modules), it can cause issues like useQuery not being found or breaking in production. This is especially problematic if the update involves changes to dependencies, the Convex client, or the way providers are set up.

Why does a full rebuild fix it?
A full rebuild ensures that both the JavaScript bundle and the native code are in sync, clearing out any mismatches or stale caches that may have been introduced by the OTA update. This is why after a full rebuild, the issue goes away, but it can reappear after the next OTA update.

Is there a way to avoid this?
The knowledge sources do not provide a definitive solution to avoid this issue entirely. However, based on community experience, here are some best practices that may help:

#
  • Avoid updating Convex or related dependencies via OTA. If you need to update Convex, convex-helpers, or make changes to how Convex is initialized, do a full rebuild and submit a new binary to the app store instead of relying on OTA.
  • Keep all dependencies up to date. Some users have found that updating all Expo and related packages after an SDK upgrade resolved similar issues, even without code changes. This suggests that dependency mismatches can contribute to the problem<source><https://discord.com/channels/1019350475847499849/1368973828839047198</source>.>
  • Minimize changes to provider setup in OTA updates. If you must push OTA updates, avoid changing how you import or initialize Convex providers and hooks.
  • Test OTA updates thoroughly. Before pushing to production, test OTA updates on real devices to catch these issues early.

Unfortunately, if the root cause is a mismatch between the JS bundle and native code or context, there is no guaranteed way to avoid this other than limiting OTA updates to UI and logic changes that do not affect native modules or provider setup.

If you continue to experience this, you may want to reach out on the Convex Discord for more targeted support, as this is a nuanced issue with Expo/React Native and not unique to Convex.

If you need more technical details or have specific error logs, please share them for further troubleshooting.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: