You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "kuncevic (via GitHub)" <gi...@apache.org> on 2025/05/25 13:13:48 UTC

[I] Unwanted Change Emission After `GET` Request during `changesAsStream() [couchdb-nano]

kuncevic opened a new issue, #350:
URL: https://github.com/apache/couchdb-nano/issues/350

   I’m using **Nano v10.1.4** with **CouchDB 3.5.0** and observed unexpected behavior with [nano.db.changesAsStream()](https://github.com/apache/couchdb-nano?tab=readme-ov-file#nanodbchangesasstreamname-params)
   
   ## Steps to Reproduce:
   1. Subscribe to `changesAsStream()` with `doc_ids: ['xyz']`.
   2. Update document `xyz` via `POST`.
   3. Perform a `GET` on document `xyz`.
   4. The stream emits a change for `xyz` (expected).
   5. Immediately after, the stream emits `xyz` again — with the same `_rev` and content as you get with the `GET` in step 3 (a side effect here).
   
   ## Observations:
   - The **GET request** caused the document to be emitted again, even though the `_rev` did not change.
   - The second emission appears to be a side effect of the `GET` request.
   - If **step 3** (GET) is skipped, only the expected change is emitted.
     
   ## Expected Behavior:
   According to the [CouchDB _changes API](https://docs.couchdb.org/en/stable/api/database/changes.html), only **write operations** (`PUT`, `POST`, `DELETE`) should trigger events — not reads like `GET`.
   
   ## Connection Options:
   
   ```js
   const options: any = {
         since: 'now',
         feed: 'continuous',
         include_docs: true,
   };
   ```
   
   For example, with `feed: 'longpoll'`, the side effect does not occur, which is expected as longpoll closes the connection after the first event. I haven't tested other feed options yet.
   
   Just trying to get to the bottom of it. Any thoughts?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Unwanted Change Emission After `GET` Request during changesAsStream() [couchdb-nano]

Posted by "glynnbird (via GitHub)" <gi...@apache.org>.
glynnbird commented on issue #350:
URL: https://github.com/apache/couchdb-nano/issues/350#issuecomment-2915686775

   I tried this with the latest CouchDB 3.5 and the latest Nano 10.1.4:
   
   ```js
   const Nano = require('nano')
   const nano = Nano(process.env.COUCH_URL)
   
   async function main() {
   
     const test = nano.db.use('test')
     const opts = {
       since: 'now',
       feed: 'continuous',
       include_docs: true
     }
     test.changesAsStream(opts).pipe(process.stdout)
   
   }
   main()
   ```
   
   Adding data:
   
   ```sh
   ccurl -X POST -d'{"a":1}' /test             
   {
     "ok": true,
     "id": "c77906581adaefba3eb6190c260025f3",
     "rev": "1-23202479633c2b380f79507a776743d5"
   }
   ```
   
   Edit data:
   
   ```sh
   ccurl -X POST -d'{"_id":"c77906581adaefba3eb6190c260025f3","_rev":"1-23202479633c2b380f79507a776743d5","a":2}' /test
   {
     "ok": true,
     "id": "c77906581adaefba3eb6190c260025f3",
     "rev": "2-71173597778497e0a6aa176963f222db"
   }
   ```
   
   Fetch data:
   
   ```sh
   ccurl /test/c77906581adaefba3eb6190c260025f3
   {
     "_id": "c77906581adaefba3eb6190c260025f3",
     "_rev": "2-71173597778497e0a6aa176963f222db",
     "a": 2
   }
   ```
   
   and I got two events:
   
   ```js
   {"seq":"15-g1AAAACbeJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOZEjFyjAnmJobmFslIpNAx5j8liAJEMDkPoPNY0dbJqRgaFpiqURNn1ZAF68MEo","id":"c77906581adaefba3eb6190c260025f3","changes":[{"rev":"1-23202479633c2b380f79507a776743d5"}],"doc":{"_id":"c77906581adaefba3eb6190c260025f3","_rev":"1-23202479633c2b380f79507a776743d5","a":1}}
   
   {"seq":"16-g1AAAACbeJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOZEjFyjAnmJobmFslIpNAx5j8liAJEMDkPqPYpqRgaFpiqURNn1ZAF7eMEs","id":"c77906581adaefba3eb6190c260025f3","changes":[{"rev":"2-71173597778497e0a6aa176963f222db"}],"doc":{"_id":"c77906581adaefba3eb6190c260025f3","_rev":"2-71173597778497e0a6aa176963f222db","a":2}}
   ```
   
   one for the insert, and one for the update. 
   
   Fetching a document does not trigger a changes feed event in CouchDB, and Nano is simply doing a CouchDB changes feed request without any magic.
   
   I should point out that the CouchDB promises to deliver each change _at least once_ not _only once_. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Unwanted Change Emission After `GET` Request during changesAsStream() [couchdb-nano]

Posted by "glynnbird (via GitHub)" <gi...@apache.org>.
glynnbird closed issue #350: Unwanted Change Emission After `GET` Request during changesAsStream()
URL: https://github.com/apache/couchdb-nano/issues/350


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org