cloudant-labs / cloudant-follow

Very stable, very reliable, NodeJS CouchDB _changes follower
Apache License 2.0
26 stars 10 forks source link

feed.filter is not working when a design document name is passed #7

Closed ceremcem closed 7 years ago

ceremcem commented 7 years ago

As title says, feed.filter = "mydesigndoc/myview" is not working. This error is thrown:

error is:  { Error: Database deleted after change: 483-g1AAAADveJzLYWBgYMlgTmFQSklKzi9KdUhJMjTWy83PzyvOyMxL1UvOyS9NScwr0ctLLckBqmVKZEiy____f1aiD6ouIzN8upIcgGRSPVijOZpGE3wa81iAJEMDkALq3Z-VWIfmVkvCmg9ANANtfpQFAF9RUgE
    at on_feed_response (/home/ceremcem/sync/curr-projects/uhud-pano-mrp/scada.js/lib/dcs/connectors/couch-dcs/node_modules/cloudant-follow/lib/feed.js:271:22)
    at Request.<anonymous> (/home/ceremcem/sync/curr-projects/uhud-pano-mrp/scada.js/lib/dcs/connectors/couch-dcs/node_modules/cloudant-follow/lib/feed.js:234:5)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at Request.onRequestResponse (/home/ceremcem/sync/curr-projects/uhud-pano-mrp/scada.js/lib/dcs/connectors/couch-dcs/node_modules/cloudant-follow/node_modules/request/request.js:1074:10)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:563:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
    at TLSSocket.socketOnData (_http_client.js:452:20)
  deleted: true,
  last_seq: '483-g1AAAADveJzLYWBgYMlgTmFQSklKzi9KdUhJMjTWy83PzyvOyMxL1UvOyS9NScwr0ctLLckBqmVKZEiy____f1aiD6ouIzN8upIcgGRSPVijOZpGE3wa81iAJEMDkALq3Z-VWIfmVkvCmg9ANANtfpQFAF9RUgE' }

If a valid function is passed, it works.

ceremcem commented 7 years ago

Here is my current workaround.

smithsz commented 7 years ago

Hey, I'm having some trouble reproducing this. I'm using this example filter from the CouchDB docs:

{
  "_id": "_design/app",
  "filters": {
    "important": "function(doc, req) { if(doc.priority == 'high') { return true; }
    else { return false; }}"
  }
}

And instantiating the follow client like so:

var feed = new follow.Feed();
feed.db = 'http://localhost:5984/testdb';
feed.filter = 'app/important';

feed.on('change', function(change) {
  console.log(`got change for doc ${change.id} (seq: ${change.seq})`);
});

feed.on('error', function(er) {
  throw er;
});

feed.follow();

Are you able to query the changes feed via curl without problems? Something similar to this:

curl 'http://localhost:5984/testdb/_changes?filter=app/important'

I'm wondering if something odd is happening on the server side, i.e. the connection is timing out. Is the filter function quite complex?

Thanks.

ceremcem commented 7 years ago

Hmmm... The problem seems that I'm actually trying to get the changes for a view, instead of a filter.