I’m using the watch() method on the web SDK to keep real time updates shown on my application screen. Sometime, for whatever reason, the watch() stops working. It can be after many hours on Chrome or almost immediately on mobile Safari.
Is there a way to detect a watch() that is no longer connected, so that I can have it reconnect upon this dropping?
i recently create a react app by using realm web template app, the web-js one, and have this error show up every few second when fetching data. i think it is related with your watch() drops issue.
Uncaught (in promise) WatchError: rule with id="62ec12a7614......" no longer exists on mongodb service, closing watch stream
at WatchStream.feedSse (bundle.dom.es.js:1812:1)
at WatchStream.feedLine (bundle.dom.es.js:1737:1)
at WatchStream.advanceBufferState (bundle.dom.es.js:1872:1)
at WatchStream.feedBuffer (bundle.dom.es.js:1716:1)
at MongoDBCollection.watchImpl (bundle.dom.es.js:2065:1)
at async watchAction (useWatch.js:45:1)
is there a better place to rise the question to find out answers
However, if I use that very same example app without any changes but using my own atlas app id, the errors show up again.
So it’s definitely connected to some backend configuration. I just don’t know which one. Will create a new test app and try to apply my settings one by one…
Does anyone have an idea what the problem might be?
It’s not the rules issue as described above for me as I’ve already deleted all default roles for testing.
@Daniel_Weiss difficult to tell, without more information, I too used the code sandbox example and it worked with a test app when I was first problem solving this issue.
I’ll provide some more information on my set-up , my code snippet from my app, and what rules looks like on my end. This was frustrating for me, so I hope this will help you solve it faster.
I’ve deleted the default permissions, and then set manual permissions on each of my collections
I finally figured it out. Having DeviceSync enabled, I assumed that those roles would take precedence and while I haven’t tested for that - I still think they do. However, the error occurs when there are no rules (not DeviceSync permissions but “normal rules”) setup. Once I did that and - importantly - no default rules as mentioned above, it did work.
So, to recap, my setup is as follows:
Rules for each collection → no default roles.
The very same rules adapted as DeviceSync permissions. Here default roles are ok.
DeviceSync is enabled
I connect to the backend via both the Flutter SDK and the Web SDK. It both works now.
Maybe this helps someone else struggling with the same problem.
I am using the Realm Web SDK and I have a custom React Hook that does the subscription for the collection watch.
The issue is that the subscription only works once. After the first subscription changes comes through, no other changes work. Is there something I am missing?