Rule with id no longer exists on mongodb service, closing watch stream - Error

I follow this official mongodb [tutorial]. (Real Time Data in a React JavaScript Front-End with Change Streams | MongoDB). Code below:

import React, { useState, useEffect } from "react"
import *  as  Realm from "realm-web";

// Create the Application
const app = new Realm.App({ id: "application-0-wfjzk" });
// Define the App component

const App = () => {
  // Set state variables
  const [user, setUser] = useState();
  const [events, setEvents] = useState([]);

  // This useEffect hook will run only once when the page is loaded

  useEffect(() => {
    const login = async () => {
      // Authenticate anonymously
      const user = await app.logIn(Realm.Credentials.anonymous());

      // Connect to the database
      const mongodb = app.currentUser.mongoClient("mongodb-atlas");
      const collection = mongodb.db("data").collection("changestream");

      // Everytime a change happens in the stream, add it to the list of events
      for await (const change of {
        setEvents(events => [, change]);
  }, []);

  // Return the JSX that will generate HTML for the page
  return (
    <div className="App">
      {!!user &&
        <div className="App-header">
          <h1>Connected as user ${}</h1>
            <p>Latest events:</p>
                <tr><td>Operation</td><td>Document Key</td><td>Full Document</td></tr>
                {, i) => (
                  <tr key={i}><td>{e.operationType}</td><td>{e.documentKey._id.toString()}</td><td>{JSON.stringify(e.fullDocument)}</td></tr>


export default App;

It’s working and If i tried to add data from atlas database it will reflect in the browser but after few seconds it shows the error below in console: Uncaught (in promise) WatchError: rule with id=“638f205a679de70c4589d429” no longer exists on mongodb service, closing watch stream
at WatchStream.feedSse (
at WatchStream.feedLine (
at WatchStream.advanceBufferState (
at WatchStream.feedBuffer (
at MongoDBCollection.watchImpl (
at async login (App.js:28:1)

After that, I can’t see the changes happening in the browser even if I add data.

Hello @Rabeeh_Ebrahim ,

Which version of the Realm Web are you using?


I have the same problem with the watch function. We are using realm web version 2.0.0 but, also tried with version 1.7.1 and had the same effect. Is there a solution to this?

The solution described here solved my problem: Detect Realm Web SDK Watch() Drops - #10 by Austin_Imperial

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.