realm-js
realm-js copied to clipboard
Realm Web: Resume and send resume tokens when watch streams ends prematurely
We should re-establish watch streams when all events are consumed, since that means the connection got closed.
We should ensure to send the _id of the last received event when resuming.
Note: Put on hold, since the server doesn't support resuming in its current state.
Is that causing "Unhandled Rejection (WatchError): rule with id="000000000000000000000000" no longer exists on mongodb service, closing watch stream"? @kraenhansen
@aureliopetrone I get that same error every 60 seconds, making watch()
essentially unusable.
This reproduces it:
const Realm = require('realm');
const REALM_APP_ID = "some_app_id";
const DB_NAME = "some_db";
const COLLECTION_NAME = "some_collection";
const app = new Realm.App(REALM_APP_ID);
Realm.App.Sync.setLogLevel(app, 'debug');
const startTime = Date.now();
const go = async () => {
const credentials = Realm.Credentials.anonymous();
const user = await app.logIn(credentials);
let changes = user.mongoClient('mongodb-atlas')
.db(DB_NAME)
.collection(COLLECTION_NAME)
.watch();
for await (const change of changes) {
console.warn("CHANGE", {change});
}
}
go().catch(error => {
const endTime = Date.now();
console.error({error, startTime, endTime, elapsed: endTime - startTime})
});
Is that causing "Unhandled Rejection (WatchError): rule with id="000000000000000000000000" no longer exists on mongodb service, closing watch stream"?
I havn't been able to reproduce this with my apps so far.
@aureliopetrone & @hgoldwire I would love for you two to create your own issues on this repository, since this issue is tracking an enhancement that won't be implemented any time soon. I'm especially interested in learning more about if you're using the Realm JS or Realm Web SDK and what sort of rules you've setup on the MongoDB Realm app. A thorough bug report makes for a faster resolution of the issue. Thanks!
Is that causing "Unhandled Rejection (WatchError): rule with id="000000000000000000000000" no longer exists on mongodb service, closing watch stream"? @kraenhansen
FYI this is a server-side bug with collection.watch()
on linked clusters that have Sync enabled. The team has a fix in progress so hopefully it should be resolved in the next cloud release without requiring any updates to realm-web
.
➤ Stoney Burks commented:
BAAS was potentially fixed but it will require more investigation from SDK to determine what is needed.
i recently used realm template app, the web-js one, and have this error show up every few second when fetching data.
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)
@kraenhansen could you please point me how to debug this issue, if i am not using watch(), is there any other way to sycn the data when event happen
@lilyFromMars Which version of Realm Web do you use?
I am using realm web 1.7.1, but I fixed issue by moving the rule from default to individual collections and the error disappeared. Although all the rules are the same.