Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

db.changesStream crashes in node 0.4.12 #33

Closed
bas-velthuizen opened this Issue · 13 comments

5 participants

bas-velthuizen Hendrik Schnepel Sascha Reuter Michael Westbom Felix Geisendörfer
bas-velthuizen

The http Client created by the db.changesStream does not have a setTimeout method.
When calling this method I get the following stack trace:

node.js:205
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
TypeError: Object #<Client> has no method 'setTimeout'
    at [object Object].changesStream (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:590:10)
    at Object.<anonymous> (/Users/bas/src/nodeJS/submitservice/service/index.js:311:16)
    at Module._compile (module.js:416:26)
    at Object..js (module.js:434:10)
    at Module.load (module.js:335:31)
    at Function._load (module.js:294:12)
    at Array.<anonymous> (module.js:454:10)
    at EventEmitter._tickCallback (node.js:197:26)

Should the code be rewritten to use the newer http.clientRequest and http.clientResponse functionality that support connection timeouts? If so, I volunteer to try to do that. If it is not necessary, let me know.

bas-velthuizen

Hmmm. Node 0.4.12 does not have setTimeout in the ClientRequest yet, it has been implemented in 0.5.4 or later...
But still...

Should there be a note in the doc that node 5.x is required?

Hendrik Schnepel

Strange.

I agree that setTimeout doesn't seem to be documented on Node v0.4.12, but I'm working with felix-couchdb and specifically the changesStream API on v0.4.12 without any problems. Thus, I would not recommend Node 5.x (it's not the stable branch as fas as I understand it?), although I understand why you are suggesting it.

Can you run the tests that come with felix-couchdb?

bas-velthuizen

Just for quickness: how do I run those? Do I need a Couch in admin-party-mode? What database is expected?

bas-velthuizen

Actually I noticed I'm working on node 5.4 on OSX.
Besides that, after I commented out the setTimeout (lib/couchdb.js:590) it works fine for my purposes, although I don't know yet if it will spontaneously end after a certain time.

Hendrik Schnepel

Okay, then it's probably an issue with the unstable branch of Node.

The default for timeout is 0 which works fine for me, so I guess leaving it out may work as well.

In case you still want to try the tests some time, I think you need an unrestricted CouchDB, or may be the tests can even be configured for basic auth?, see ./test/common.js. Then just run make test or node ./test/test-{whatever}.js in felix-couchdb's base directory. One or two test databases may be created by the tests, no preparation needed.

bas-velthuizen

ok: test results on node v4.12 on OS X snow leopard:

bas@bas-laptop /Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb$node ./test/test-db.js 
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace: 
    at Client.<anonymous> (events.js:126:17)
    at [object Object]._queueRequest (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:158:16)
    at [object Object].request (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:269:15)
    at [object Object].request (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:341:24)
    at [object Object].allDocs (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:499:15)
    at Object.<anonymous> (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/test/test-db.js:124:4)
    at Module._compile (module.js:411:26)
    at Object..js (module.js:417:10)
    at Module.load (module.js:343:31)
    at Function._load (module.js:302:12)

/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/test/test-db.js:133
    if (er) throw new Error(JSON.stringify(er));
                  ^
Error: {"error":"not_found","reason":"missing"}
    at /Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/test/test-db.js:133:19
    at IncomingMessage.<anonymous> (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:190:26)
    at IncomingMessage.emit (events.js:81:20)
    at HTTPParser.onMessageComplete (http.js:133:23)
    at Client.onData [as ondata] (http.js:1488:27)
    at Client._onReadable (net.js:677:27)
    at IOWatcher.onReadable [as callback] (net.js:177:10)
bas@bas-laptop /Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb$node ./test/test-client.js 
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace: 
    at Client.<anonymous> (events.js:126:17)
    at [object Object]._queueRequest (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:158:16)
    at [object Object].request (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:269:15)
    at [object Object].request (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:341:24)
    at [object Object].create (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/lib/couchdb.js:368:15)
    at Object.<anonymous> (/Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb/test/test-client.js:68:5)
    at Module._compile (module.js:411:26)
    at Object..js (module.js:417:10)
    at Module.load (module.js:343:31)
    at Function._load (module.js:302:12)

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: ECONNREFUSED, Connection refused
    at Client._onConnect (net.js:595:18)
    at IOWatcher.onWritable [as callback] (net.js:186:12)
bas@bas-laptop /Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb$node ./test/test-attachment.js 
bas@bas-laptop /Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb$node ./test/test-request.js 
bas@bas-laptop /Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb$node ./test/test-to-query.js 
bas@bas-laptop /Users/bas/src/nodeJS/submitservice/service/node_modules/felix-couchdb$node ./test/test-changes.js 

Ah, and the changes-test just keeps waiting :)

bas-velthuizen

But the code works, including the setTimeout, on node 0.4.12

Hendrik Schnepel

Oh right, I recently fixed the test suite to work with CouchDB 1.0.1 and Node v0.4.12. It's on Felix' trunk but not on npm yet, I guess.

bas-velthuizen

ok, latest changes on trunk test without errors and messages on OS X , Node v0.4.12

bas-velthuizen bas-velthuizen reopened this
bas-velthuizen

For the new stable node version: v0.6.0, this issue is current again:

bas@bas-laptop /Users/bas/src/nodeJS/node-couchdb$make test        
node test/test-attachment.js
node test/test-changes.js

/Users/bas/src/nodeJS/node-couchdb/lib/couchdb.js:599
  client.setTimeout(options.timeout);
         ^
TypeError: Object #<Client> has no method 'setTimeout'
    at [object Object].changesStream (/Users/bas/src/nodeJS/node-couchdb/lib/couchdb.js:599:10)
    at /Users/bas/src/nodeJS/node-couchdb/test/test-changes.js:21:21
    at IncomingMessage.<anonymous> (/Users/bas/src/nodeJS/node-couchdb/lib/couchdb.js:195:26)
    at IncomingMessage.emit (events.js:88:20)
    at HTTPParser.onMessageComplete (http.js:137:23)
    at Socket.ondata (http.js:1125:24)
    at TCP.onread (net.js:334:27)
node test/test-client.js

assert.js:104
  throw new assert.AssertionError({
        ^
AssertionError: Callback G fired
    at /Users/bas/src/nodeJS/node-couchdb/test/common.js:9:12
    at EventEmitter.<anonymous> (/Users/bas/src/nodeJS/node-couchdb/test/test-client.js:122:3)
    at EventEmitter.emit (events.js:64:17)
node test/test-db.js
node test/test-request.js
node test/test-to-query.js
make: *** [test] Error 1
Hendrik Schnepel

Confirmed ;(

Sascha Reuter

+1

Felix Geisendörfer felixge closed this issue from a commit
Hendrik Schnepel use http api of node v6.x (fixes #33) 5feb65c
Felix Geisendörfer felixge closed this in 5feb65c
Michael Westbom

This issue appears for me in node 0.6.11.


module.js:311
    throw err;
          ^
TypeError: Object #<Client> has no method 'setTimeout'
    at [object Object].changesStream (/home/mwestbom/node_modules/felix-couchdb/
lib/couchdb.js:599:10)
    at Object.<anonymous> (/home/mwestbom/.ircnode/plugins/paste_watch.js:12:23)

    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.oncomplete (/home/mwestbom/node_modules/ircnode/client.js:334:20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.