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

the result from useQuery is not usable in adding subscriptions. #4507

Closed
sync-by-unito bot opened this issue Apr 20, 2022 · 4 comments · Fixed by #4541
Closed

the result from useQuery is not usable in adding subscriptions. #4507

sync-by-unito bot opened this issue Apr 20, 2022 · 4 comments · Fixed by #4541
Assignees

Comments

@sync-by-unito
Copy link

sync-by-unito bot commented Apr 20, 2022

No description provided.

@sync-by-unito
Copy link
Author

sync-by-unito bot commented Apr 20, 2022

➤ On 2022-03-24, Kenneth Geisshirt commented:

We need to include FLX support as a requirement for sync support of Realm React: https://jira.mongodb.org/browse/RJS-1517

@tomduncalf
Copy link
Contributor

tomduncalf commented Apr 28, 2022

It seems that the way React Native implements ES6 Proxy is not compatible with how our is_instance function works. is_instance calls has_instance, which calls the JSC JSValueIsObjectOfClass function.

This function should handle Proxy instances by looking at the proxy target, but this doesn't work with React Native – this can be tested by wrapping a Results instance in a Proxy, entirely bypassing Realm React, and passing it to MutableSubscriptions::add – it will fail on React Native.

This works as expected on Node (which is obviously a different runtime) and on Hermes.

tomduncalf pushed a commit that referenced this issue Apr 29, 2022
… properly with JSC.

This change can be reverted once we go to v11. Fixes #4507
@tomduncalf
Copy link
Contributor

Closing in favour of waiting for v11 to be released which uses JSI and will fix the fundamental Proxy issue. Workaround for now is to pass in the results directly, e.g.

const people = useQuery(realm.objects('Person'));
// ...
realm.subscriptions.update(subs => {
  subs.add(people); // this will error
});

becomes

const results = realm.objects('Person');
const people = useQuery(people);
// ...
realm.subscriptions.update(subs => {
  subs.add(results); // no error as we are passing in the Realm.Results instance directly
});

tomduncalf pushed a commit that referenced this issue May 25, 2022
… properly with JSC.

This change can be reverted once we go to v11. Fixes #4507
@tomduncalf
Copy link
Contributor

tomduncalf commented May 25, 2022

We have decided to implement this workaround

@tomduncalf tomduncalf reopened this May 25, 2022
tomduncalf pushed a commit that referenced this issue May 26, 2022
… properly with JSC. (#4541)

* Add a workaround for React Native `Proxy` objects pre-JSI not working properly with JSC.

This change can be reverted once we go to v11. Fixes #4507
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant