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

Can't close MongoDB watch stream

      How frequently does the bug occur?

      All the time

      Description

      I can't close the watch stream unless I get at least one change from the stream.
      watch.return() only works when the for loop is executed at least once.

      Stacktrace & log output

      No response

      Can you reproduce the bug?

      Yes, always

      Reproduction Steps

      const watch = col.watch({
        filter: {
          operationType: "insert",
        },
      });
      
      setTimeout(() => {
        console.log("timed out");
        watch.return();
      }, 10 * 1000);
      
      for await (const change of watch) {
        const { fullDocument } = change;
        console.dir(fullDocument);
      }
      
      console.log("this is never printed");
      

      I don't insert a document for 10 seconds, then it should run the last console.log, but it doesn't and stuck in for loop.
      If I insert one within 10 seconds, it works as expected.

      Version

      "realm": "11.3.0"

      What SDK flavour are you using?

      Atlas App Services (auth, functions, etc.)

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      Node

      Build environment

      Which debugger for React Native: ..

      Cocoapods version

      No response

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

              Created:
              Updated: