Skip to content

[0.74.0-rc.1] Invariant violation when accessing TurboModules #43213

Closed
@tido64

Description

@tido64

Old Version

0.73.4

New Version

0.74.0-rc.1

Description

If a New Architecture enabled library implements ReactModuleInfoProvider using a pattern like below:

    override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
        val info = ReactModuleInfo(
            WebStorageModule.NAME,
            WebStorageModule::class.java.name,
            false,
            false,
            false,
            false,
            TurboModule::class.java.isAssignableFrom(WebStorageModule::class.java)  // <-- THIS
        )
        mapOf(info.name() to info).toMutableMap()
    }

It will no longer be detected as a TurboModule because TurboModule::class.java.isAssignableFrom() will now return false. The reason is because the TurboModule class used here is no longer the same TurboModule class used for the generated spec: b7191cd

Quite a number of libraries currently use this pattern: https://github.com/search?q=TurboModule.class.isAssignableFrom&type=code

Steps to reproduce

git clone https://github.com/microsoft/react-native-test-app.git
cd react-native-test-app
npm run set-react-version 0.74 -- --core-only
yarn
cd example
yarn android --extra-params "-PnewArchEnabled=true"

# In a separate terminal
yarn start

Affected Platforms

Runtime - Android, Build - MacOS

Output of npx react-native info

n/a

Stacktrace or Logs

n/a

Reproducer

https://github.com/microsoft/react-native-test-app.git

Screenshots and Videos

n/a

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions