Upgrading to SDK 46: Invariant Violation: No callback found with cbID 2 and callID 1 for module <unknown>

Please provide the following:

  1. SDK Version: 46
  2. Platforms(Android/iOS/web/all): all
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

We are currently on SDK 45 and tried to upgrade to 46.

However, we encounter problems we are not sure about how to fix them.

Here is the error trace:

 ERROR  Invariant Violation: No callback found with cbID 2 and callID 1 for module <unknown>. Args: '[{"app_state":"active"}]'
 ERROR  Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
Text@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:65796:27
Root
ExpoRoot@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:223483:22
RCTView
View
DevAppContainer@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:223230:36
RCTView
View
AppContainer@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:184801:36
main(RootComponent)@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:190723:28
 ERROR  Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
Text@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:65796:27
Root
ExpoRoot@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:223483:22
RCTView
View
DevAppContainer@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:223230:36
RCTView
View
AppContainer@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:184801:36
main(RootComponent)@http://192.168.1.47:19000/index.bundle?platform=ios&dev=true&hot=false:190723:28
 ERROR  TypeError: null is not an object (evaluating 'dispatcher.useState')

This error is located at:
    in Text
    in Root (created by ExpoRoot)
    in ExpoRoot
    in RCTView (created by View)
    in View (created by AppContainer)
    in DevAppContainer (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent)

My question is what exactly does

 ERROR  Invariant Violation: No callback found with cbID 2 and callID 1 for module <unknown>. Args: '[{"app_state":"active"}]'

mean and where does it originate from?

To keep things simple we modified our App.tsx to:

import React from 'react';
import { Text } from 'react-native';

export default function Root() {
  return <Text>Test</Text>;
}

And our index.js is:

import { registerRootComponent } from 'expo';

import App from './App';

registerRootComponent(App);

We run this in a monorepo where other applications may have other react and react-dom versions. But even after downgrading them all to 18.0.0 this error in our mobile app persists.

Expo doctor says everything is :+1:

$ expo doctor
🎉 Didn't find any issues with the project!

Hey @nephix,

This seems like an issue because the mobile app project is in a monorepo and is usually caused by multiple versions of a dependency. We recently updated the Monorepos guide to address this. Please refer modify the metro config section to use disableHierarchicalLookup which allows a monorepo to include multiple versions of the react package.

1 Like

Thanks @amanhimself !

This seems to have an effect.

I’m now getting:

iOS Bundling failed 241ms
Unable to resolve "uuid/v5" from "../../node_modules/expo/build/environment/getInstallationIdAsync.js"

when running our mobile project.

Is that something we should add as a dependency on our side?

We use npm workspaces and have the following monorepo structure

node_modules
apps/mobile <-- on expo sdk 46

EDIT:
Ok we have uuid as a dependency already in another package:

    "uuid": "^8.3.2",

so it’s already in node_modules

Unable to resolve "uuid/v5" from "../../node_modules/expo/build/environment/getInstallationIdAsync.js"

[/quote]
Can you try importing it like this: import { v5 as uuidv5 } from "uuid";?

iOS Bundling complete 411ms
 ERROR  Error: crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

You’ll have to follow the steps mentioned here: GitHub - uuidjs/uuid: Generate RFC-compliant UUIDs in JavaScript. It’s a polyfill for libraries like uuid.

But these errors all originate from expo packages within node_modules, not our mobile app.

We use the uuid package in our monorepo, but on the server side and not within the Expo app.

The error occurs with our app code being:

import React from 'react';
import { Text } from 'react-native';

export default function Root() {
  return <Text>Test</Text>;
}

Isn’t that something that needs to be fixed within some Expo package?

I created a minimal repo to reproduce the issue here: GitHub - nephix/expo-46-monorepo

git clone git@github.com:nephix/expo-46-monorepo.git
cd expo-46-monorepo
npm install
cd packages/mobile
npm run ios

When you run these, you should also get:

iOS Bundling failed 3806ms
Unable to resolve "uuid/v5" from "../../node_modules/expo/build/environment/getInstallationIdAsync.js"

All I did was create an empty monorepo which only has "uuid": "^9.0.0" as dependency and then initialized a new expo 46 TypeScript app within packages

Thanks for sharing the reproducible example. I’ll check it on my end and let you know.

1 Like

Hey @nephix,

We looked into the issue and it doesn’t seem an Expo related issue. It seems to be a hoisting issue with the type of workspace you use.

We usually recommend Yarn workspaces for monorepos. You can also find the details in the documentation: Working with Monorepos - Expo Documentation

If you are setting up with Yarn workspaces, I’d suggest going through: nohoist in Workspaces | Yarn Blog as well as go through the common issues section in Expo docs: Working with Monorepos - Expo Documentation

2 Likes

Hey @amanhimself

thanks for looking into it. So the problem is the way how npm workspaces and their hoisting were implemented?

We tried yarn but didn’t really see any benefits after npm introduced workspaces. But I guess we’ll have to look into it again.

Thanks for explanation and links

1 Like

Yeah, I’d suggest you to look into the hoisting part of the npm worksapces.

@amanhimself I’m seeing this exact same issue with SDK 46 and yarn workspaces. I am not using hoisted per the default monorepo docs. The weird thing is expo go was working great for a while and just suddenly stopped with no changes in dependencies, now I’m not able to get expo to run at all.

I tried @nephix repo with yarn workspaces and experienced the same issue.

Hey @why_jeff,

What error are you seeing when you are running npx expo start or when starting the development server?

Unable to resolve "uuid/v5" from "../../node_modules/expo/build/environment/getInstallationIdAsync.js" on app load.

Running with yarn workspace mobile ios

What’s even more baffling is now the example repo linked in this issue (modified from npm workspace example in this thread): SDK46: Unable to resolve module uuid/v5 in expo go · Issue #19160 · expo/expo · GitHub is not failing now (it was failing when I put it together earlier) but my main work project is still showing this issue…

it looks like the dependency tree in your yarn workspace is leading to importing an unexpected version of uuid. it should be importing uuid@3.4.0

run yarn why uuid and see which versions are being installed, to where, and why

1 Like

@brents ah, good catch thank you, if I nohoist the uuid dep it works. That makes sense, I guess I was confused since the expo docs mention not using hoisting. Relatively new to yarn workspaces so that was confusing. Thanks!

We chose to stay with npm workspaces and did the following to make it work:

  1. Downgrade our uuid dependency to ^3.4.0 (same as used in Expo)
  2. rm -rf package-lock.json in monorepo root
  3. npm install in monorepo root

Then the uuid errors disappeared.

Hopefully npm is going to add a nohoist option for workspaces in the future so we can use uuid in more recent versions in other packages of our monorepo

1 Like