Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Exception in HostFunction: Cannot set the logger factory after creating the sync client #6005

Closed
mednche opened this issue Jul 21, 2023 · 4 comments

Comments

@mednche
Copy link

mednche commented Jul 21, 2023

How frequently does the bug occur?

Always

Description

I cannot seem to be able to use Realm.App.Sync.setLogLevel() or Realm.App.Sync.setLogger() in my react native app.

If I place Realm.App.Sync.setLogger() BEFORE const app = new Realm.App(appConfig); I get:
"Error: Exception in HostFunction: app must be of type 'object', got (undefined)". This makes sense to me, as app has not be defined yet.

If I place it straight AFTER const app = new Realm.App(appConfig);, I get:
"Error: Exception in HostFunction: Cannot set the logger factory after creating the sync client". Why am I getting this?

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

const appConfig = {
    id: appId,
    timeout: 10000,
    app: {
      name: "default",
      version: "0",
    },
  };

Realm.App.Sync.setLogLevel(app, "debug"); // "all", "debug", "error", "info", "trace"
Realm.App.Sync.setLogger(app, (level, message) => console.log(`[${level}] ${message}`));

const app = new Realm.App(appConfig);

// I've also tried to place it here instead
// Realm.App.Sync.setLogLevel(app, "debug"); // "all", "debug", "error", "info", "trace"
// Realm.App.Sync.setLogger(app, (level, message) => console.log(`[${level}] ${message}`));### Version

[email protected]

What services are you using?

Both Atlas Device Sync and Atlas App Services

Are you using encryption?

No

Platform OS and version(s)

NA

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

@takameyer
Copy link
Contributor

@mednche Thanks for creating this issue! The second example of setting the logger is the correct way. What version of Realm are you using?

@mednche
Copy link
Author

mednche commented Jul 28, 2023

The second example of setting the logger is the correct way. What version of Realm are you using?

I'm using [email protected]. When I use the second example of setting the logger, I get "Error: Exception in HostFunction: Cannot set the logger factory after creating the sync client". Any idea what tends to cause this error?

@kneth
Copy link
Contributor

kneth commented Aug 14, 2023

@mednche Sorry for the late reply.

It sounds like you are setting the logger after opening the Realm. It is not supported - you see to set the logger and loglevel before opening any Realm.

@kneth
Copy link
Contributor

kneth commented Oct 31, 2023

I am closing the issue due to no reply back. Please create a new issue if you have new observations to share.

@sync-by-unito sync-by-unito bot closed this as completed Oct 31, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants