Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-958

[realm-web] can't close watch stream

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      <!---

      Questions: If you have questions about HOW TO use Realm, please ask on
      StackOverflow: http://stackoverflow.com/questions/ask?tags=realm
      We monitor the realm tag.

      Feature Request: Just fill in the first two sections below.

      Bugs: To help you as fast as possible with an issue please describe your issue
      and the steps you have taken to reproduce it in as much detail as possible.

      -->

      Goals

      Ability to close a watch stream when destroying a component

      Expected Results

      Watch stream closes and doesn't receive updates.

      Actual Results

      .close() does not exist and the connection stays active

      Steps to Reproduce

      • Create a new watch stream on the collection
      • Destroy component (vue/react)
      • Update a document in the collection and it will still be listening

      Code Sample

      // Watch for future comments
      const mongo = realmUser.mongoClient('mongodb-atlas').db('DATABASE')
      const mongoCollection = await mongo.collection('COLLECTION')
      
      for await (const change of mongoCollection.watch({
        ids: [this.request._id],
      })) {
        console.log(change)
        this.comments = change.fullDocument.Comments
      }
      

      Version of Realm and Tooling

      • realm-web 1.0.0
      • vue 2.6.11

      Extra info

      This works fine in a previous projects using the Stitch SDK. There you could call .close() on the watch stream. Maybe I'm overlooking something in the new realm-web sdk?

      Thanks!

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: