Realm-js: Enabling React Native Debug mode causes Error: _expandEmbeddedObjectSchemas must be of type 'function', got (undefined)

Created on 6 Dec 2020  路  2Comments  路  Source: realm/realm-js

Goals


Enable React Native Debug mode in order to troubleshoot console errors, set breakpoints, profile app, and monitor network requests.

Expected Results

Mobile app connects to React Native Debugger successfully and I'm able to set breakpoints, profile app, and monitor network requests, view console errors

Actual Results

Mobile App crashes with the following error

Error: _expandEmbeddedObjectSchemas must be of type 'function', got (undefined)



image

image

Steps to Reproduce

  1. Run yarn ios to build react native application and install on device.
  2. Shake device to reveal developer menu and select Debug .
    image
  3. An exception occurs on mobile app.
Component Exception
_expandEmbeddedObjectSchemas must be of type 'function', got (undefined)

Code Sample

import React, { useEffect, useState } from 'react'
import { SafeAreaView, Text } from 'react-native'
import Realm from 'realm'

const App = () => {
    const [realmDB, setRealmDB] = useState<Realm>()

    useEffect(() => {
        Realm.open({
            schema: [{ name: 'Dog', properties: { name: 'string' } }],
        }).then(realm => {
            realm.write(() => {
                realm.create('Dog', { name: 'Rex' })
            })
            setRealmDB(realm)
        })

        return () => {
            if (realmDB) {
                realmDB.close()
            }
        }
    }, [])

    return (
        <SafeAreaView>
            <Text>{realmDB ? 'Number of dogs: ' + realmDB.objects('Dog').length : 'Loading'}</Text>
        </SafeAreaView>
    )
}

export default App

Version of Realm and Tooling

  • Realm JS SDK Version: 10.0.2
  • Node or React Native: 0.63.3
  • Client OS & Version: Iphone 7, iOS 14.2
  • Which debugger for React Native: React Native Debugger 0.11.5
O-Community T-Bug

Most helpful comment

Thanks for reporting this.

I admit (and this is truly unfortunate) that we don't have in-depth integration tests for our library when running in Chrome debugging mode. The app that I was using to test the fix in #3411 inferred its schema, which lead to the unfortunate consequence that I didn't catch this case when solving the other issues.

I have a PR ready with a fix for this in #3446, which is currently in review and you can expect a new release as soon as this gets merged. Thank you all for your patience on this.

All 2 comments

This is happening also in android with the example of the docs. If debug mode is not enabled, works like a charm.

Thanks for reporting this.

I admit (and this is truly unfortunate) that we don't have in-depth integration tests for our library when running in Chrome debugging mode. The app that I was using to test the fix in #3411 inferred its schema, which lead to the unfortunate consequence that I didn't catch this case when solving the other issues.

I have a PR ready with a fix for this in #3446, which is currently in review and you can expect a new release as soon as this gets merged. Thank you all for your patience on this.

Was this page helpful?
0 / 5 - 0 ratings