realm-js: React Native app crashes if `onFirstOpen` exists in Realm configuration

How frequently does the bug occur?

All the time

Description

I’m trying to populate my database with some initial data with onFirstOpen config, but if I’m specifying it the app crashes as soon as it called without any errors

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, always

Reproduction Steps

createRealmContext({
    ...
    onFirstOpen: (realm) => {
      console.log("init realm?", realm.create);
      // Create default categories
      categories.forEach((r) => {
        realm.create(
          "Category",
          Category.create({
            ...
          })
        );
      });

      // Create currencies
      currencies.forEach((r) => {
        realm.create(
          "Currency",
          Currency.create({
            ...
          })
        );
      });
    },
  });

Version

10.20.0-beta.5

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

iOS 15.0

Build environment

Which debugger for React Native: Flipper Expo SDK 45

Cocoapods version

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 26 (14 by maintainers)

Most upvoted comments

@KMuteteke @HighDeck I have reopened the issue so we can investigate it.

Sure! https://docs.expo.dev/build/setup/#1-install-the-latest-eas-cli

You can skip Step 3 as the project already configured for EAS and on Step 4 use eas build --platform {{ platform }} --profile simulator

@takameyer i was unable to test it out because of project migration to expo 45 and impossibility to finish migration to realm, still going to test this out with new rc