djc / couchdb-python

Python library for working with CouchDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes feed does not work with couchbase sync gateway

hermitdemschoenenleben opened this issue · comments

In Couchbase sync gateway's changes feed, chunks don't necessarily correspond to documents, i.e. a JSON object can be truncated. However, couchdb-python calls iterchunks() and tries do decode each single element using JSON which obviously will fail as the JSON object may be truncated.
In order to fix this, I created a quick fix:
25b164e
The new iterdocs method tries to decode each chunk, if this fails due to truncation, the current line is saved in a buffer and decoding is retried once the next chunk is there.

However, this is probably not the best / most elegant way to do this.

aiocouchdb apparently had the same issue, was fixed like this: aio-libs/aiocouchdb@6e63d05

Fixed in #289.