Results.removeAllListeners throw Error: Value is undefined, expected an Object #6217
Labels
Encryption:Off
Frequency:Always
More-information-needed
More information is needed to progress. The issue will close automatically in 2 weeks.
O-Community
Repro:Always
SDK-Use:Sync
T-Bug
Waiting-For-Reporter
Waiting for more information from the reporter before we can proceed
How frequently does the bug occur?
Always
Description
First of all, this error is only happening in React Native, I use the same code in a Electron/NodeJS environment and it works as expected.
Expected to call
removeAllListeners
and successfully remove listeners. Instead it gives me the errorError: Value is undefined, expected an Object
.To better understand this issue, you can check this link to see how I'm calling
removeAllListeners
function, because I don't keep a reference ofRealm.Results
, so instead I keep a reference of theremoveAllListeners
function.Stacktrace & log output
Can you reproduce the bug?
Always
Reproduction Steps
Example that throws the error:
The first execution will always work as expected, but the second time this function is called,
unsubListener
will have a reference toitems.removeAllListeners
, and by callingunsubListener()
, it throws the error mentioned in this issue.Example that works as expected:
I noticed that this issue is related to keeping the reference of
removeAllListeners
in a variable, because the code above works without any issue, but I didn't want to keep a reference of all results just to remove listeners later on. What I can't figure it out is why does it work fine in a NodeJS environment, but not on React Native.Version
11.7.0
What services are you using?
Atlas Device Sync
Are you using encryption?
No
Platform OS and version(s)
macOS Monterey 12.6
Build environment
Which debugger for React Native: ..
Cocoapods version
No response
The text was updated successfully, but these errors were encountered: