Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-889

ChangeStreamCursor not immediately initialized

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.1
    • Component/s: Shell API
    • Labels:
      None
    • Documentation Changes:
      Not Needed
    • Sprint:
      Iteration Geneva

      Description

      as reported in #mongosh on Slack:

      replset [primary] test> var changeStream = db.watch()
      ChangeStreamCursor on test
      replset [primary] test> db.foo.insert({name:"John"})
      DeprecationWarning: Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite.
      {
        acknowledged: true,
        insertedIds: { '0': ObjectId("60ec1c6464ec76b1492fae72") }
      }
      replset [primary] test> changeStream.next()
      Warning: If there are no documents in the batch, next will block. Use tryNext if you want to check if there are any documents without waiting.
      

      replset:PRIMARY> var changeStream = db.watch()
      replset:PRIMARY> db.foo.insert({name: "foo"})
      WriteResult({ "nInserted" : 1 })
      replset:PRIMARY> changeStream.next()
      {
      	"_id" : {
      		"_data" : "8260EC1C9E000000012B022C0100296E5A1004627EABB2BF0E4DDB8D434E0CB526A8B046645F6964006460EC1C9E42E74AB99614C8460004"
      	},
      	"operationType" : "insert",
      	"clusterTime" : Timestamp(1626086558, 1),
      	"fullDocument" : {
      		"_id" : ObjectId("60ec1c9e42e74ab99614c846"),
      		"name" : "foo"
      	},
      	"ns" : {
      		"db" : "test",
      		"coll" : "foo"
      	},
      	"documentKey" : {
      		"_id" : ObjectId("60ec1c9e42e74ab99614c846")
      	}
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              anna.henningsen Anna Henningsen
              Reporter:
              anna.henningsen Anna Henningsen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: