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

getSyncSession cannot resolve session even though it exsist #6582

Open
deckyfx opened this issue Apr 3, 2024 · 6 comments
Open

getSyncSession cannot resolve session even though it exsist #6582

deckyfx opened this issue Apr 3, 2024 · 6 comments
Assignees

Comments

@deckyfx
Copy link

deckyfx commented Apr 3, 2024

How frequently does the bug occur?

Always

Description

I have this piece of code

console.log('getCurrentPartitionValue()', getCurrentPartitionValue());
syncSession = Realm.App.Sync.getSyncSession(
  realmApp().currentUser,
  getCurrentPartitionValue(),
);
console.log('syncSession', syncSession);

const sessions = Realm.App.Sync.getAllSyncSessions(
  realmApp().currentUser,
);
console.log('sessions', sessions);
syncSession = sessions.find(session => {
  return session.config.partitionValue === getCurrentPartitionValue();
});
console.log('syncSession', syncSession);

the output is this

 LOG  getCurrentPartitionValue() 655d5e27fce9035abdbe2654
 LOG  syncSession null
 LOG  sessions [{}]
 LOG  syncSession {}
 LOG  syncSession {"partitionValue": "655d5e27fce9035abdbe2654", "user": {}}

As you can see, the same partition value and user, used in getSyncSession yield null, yet if I resolve it via getAllSyncSessions, it is exsist

Stacktrace & log output

getCurrentPartitionValue() 655d5e27fce9035abdbe2654
syncSession null
sessions [{}]
syncSession {}
syncSession {"partitionValue": "655d5e27fce9035abdbe2654", "user": {}}

Can you reproduce the bug?

Always

Reproduction Steps

Realm.App.Sync.getSyncSession

Version

^11.10.2

What services are you using?

Both Atlas Device Sync and Atlas App Services

Are you using encryption?

Yes

Platform OS and version(s)

WSL2 on Windows 11

Build environment

Which debugger for React Native: ..

Cocoapods version

Copy link

sync-by-unito bot commented Apr 3, 2024

➤ PM Bot commented:

Jira ticket: RJS-2785

@kneth
Copy link
Member

kneth commented Apr 4, 2024

In our current main branch, we have the following tests: https://github.com/realm/realm-js/blob/main/integration-tests/tests/src/tests/sync/sync-session.ts#L625-L644

I suggest you to upgrade to a recent version (for example v12.6.0), and if the issue is still observed, please let us know.

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Apr 4, 2024
@deckyfx
Copy link
Author

deckyfx commented Apr 15, 2024

using 12.6.2
Realm.App.Sync.getSyncSession yield null
while Realm.App.Sync.getAllSyncSessions yield {"weakInternal": {Symbol(Realm.WeakSyncSession.external_pointer): {}}}

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Apr 15, 2024
@sync-by-unito sync-by-unito bot removed the Needs-Attention Reporter has responded. Review comment. label Apr 22, 2024
@vatsal-gadhiya-searce
Copy link

@kneth We are also getting the same error in the syncError when we close the app and reopen the app again. But if we logout and login again there is no more error.

const syncConfigWithErrorHandling = {
flexible: true,
onError: (_session, error) => {
console.log(error);
},
};
function RealmWithErrorHandling() {
return (



);
}

@vatsal-gadhiya-searce
Copy link

I have upgraded to 12.7.1 latest and the issue is still same. we are getting weakInternal error.

@kneth
Copy link
Member

kneth commented Apr 26, 2024

In #6637 we are reworking how getSyncSession() is implemented due to a refactoring in Realm Core. I hope it will solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants