Reputation: 1679
I am using PouchDB
on client side and CouchDB
on server side. My client need to replicate data from the server using a filter.
Here is the client code I am using:
_db.replicate.from(_remote_db, {
filter: "repl/myfilter",
live: false,
retry: true,
query_params: {
group: '11'
}
}).on('change', (info) => {
dbReplChangeHandler(_db, _db_analytics, info, deferred);
})
While the design document in the couchDB
database is :
{
"_id": "_design/repl",
"_rev": "19-3848f574d651345540379c06b67699bb",
"filters": {
"myfilter": "function (doc, req){return true;}"
}
}
The client is still not able to replicate from the server throwing this error timeout,{gen_server,call,\n [couch_proc_manager,}
Upvotes: 1
Views: 626
Reputation: 11
The issue seems to be with couchdb 2.1.1 (I confirmed this behavior on a Mac, don't know if it exist on other platforms). Is quite simple to reproduce:
1) Create a test database
curl -vX PUT http://localhost/testdb
2) Populate with documents
for i in {1..5}; do curl -vX PUT http://localhost/testdb/00$i -d '{"type":"A", "description":"Document 00$i"}'; done;
3) Test that you can see the documents
curl -X GET http://localhost/testdb/_changes?since=0
You'll see an output similar to the following:
{"results":[
{"seq":"3-g1AAAAB5eJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOZE5FyjAnmiWlmhuaIhNAx5j8liAJEMDkPoPMi2RIQsAx5cmmw","id":"001","changes":[{"rev":"3-c9fb50f5d39cdac66a342dfac914fc52"}]},
{"seq":"4-g1AAAAB5eJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOZElFyjAnmiWlmhuaIhNAx5j8liAJEMDkPoPMi2RIQsAx-UmnA","id":"004","changes":[{"rev":"1-987569f1cc05eaf1bad8793d290adab2"}]},
{"seq":"5-g1AAAAB5eJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOZE1FyjAnmiWlmhuaIhNAx5j8liAJEMDkPoPMi2RIQsAyDMmnQ","id":"005","changes":[{"rev":"1-987569f1cc05eaf1bad8793d290adab2"}]},
{"seq":"7-g1AAAACbeJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOZE1FyjAnmiWlmhuaIhNAx5j8liAJEMDkPoPNY0JbFqaoVGSobkxNn1ZAHN1MJo","id":"002","changes":[{"rev":"1-987569f1cc05eaf1bad8793d290adab2"}]},
{"seq":"8-g1AAAACbeJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOZE1FyjAnmiWlmhuaIhNAx5j8liAJEMDkPoPNY0ZbFqaoVGSobkxNn1ZAHOXMJs","id":"003","changes":[{"rev":"1-987569f1cc05eaf1bad8793d290adab2"}]},
"last_seq":"9-g1AAAACbeJzLYWBgYMpgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUklMiTV____PyuDOZE1FyjAnmiWlmhuaIhNAx5j8liAJEMDkPoPNY0FbFqaoVGSobkxNn1ZAHO5MJw","pending":0}
4) Create a simple 'accept all' filter
curl -vX PUT http://localhost/testdb/_design/test -d '{"filters":{"everything":"function(doc, req){return true;}"}}'
5) Apply the filter to the _changes command
curl -X GET http://localhost/testdb/_changes?filter=test/everything&since=0
Now you will see something like this:
{
"error": "error",
"reason": "{timeout,{gen_server,call,
[couch_proc_manager,
{get_proc,{doc,<<\"_design/test\">>,
{1,
[<<251,118,3,66,28,132,147,60,168,234,
101,119,87,97,205,255>>]},
{[{<<\"filters\">>,
{[{<<\"everything\">>,
<<\"function(doc, req){return true;}\">>}]}}]},
],false,[]},
{<<\"_design/test\">>,
<<\"1-fb7603421c84933ca8ea65775761cdff\">>}},
5000]}}"
}
This is with version 2.1.1, I've confirmed that the version 2.1.1-1 (not released yet) works (at least for this case), which you can find here.
If your problem happens on windows or linux, you might want to downgrade to version 2.1.0 or 2.0.
Hope this helps
Upvotes: 1