Giter VIP home page Giter VIP logo

node-couchdb's Introduction

Now maintained and active!!!

I'd like to thank Felix for creating this and hope you find it useful when working with node and couchDB.

Node.js CouchDB module

A thin node.js idiom based module for CouchDB's REST API that tries to stay close to the metal.

Tutorial

Installation is simple from NPM:

$ npm install felix-couchdb

To use the library, create a new file called my-couch-adventure.js:

var
  util = require('util'),
  couchdb = require('felix-couchdb'),
  client = couchdb.createClient(5984, 'localhost'),
  db = client.db('my-db');

db
  .create(function(er){
    if (er) throw new Error(JSON.stringify(er));
    util.puts('Created new db.');
  });

db
  .saveDoc('my-doc', {awesome: 'couch fun'}, function(er, ok) {
    if (er) throw new Error(JSON.stringify(er));
    util.puts('Saved my first doc to the couch!');
  });

db
  .getDoc('my-doc', function(er, doc) {
    if (er) throw new Error(JSON.stringify(er));
    util.puts('Fetched my new doc from couch:');
    util.p(doc);
  });

If you are wondering if there is a race-condition in the above example, the answer is no. Each couchdb.Client uses an internal queue for its requests, just like http.Client. This guarantees ordering. If you want to perform multiple requests at once, use multiple couchdb.Client instances.

API Documentation

Callbacks

All asynchronous functions are performed with callbacks. Callback functions are always the last argument, and always receive one or two arguments. The first argument is an error object or null if no error occurs. The second is the data returned by the function in question, if appropriate.

The callback argument is optional. If not supplied, then errors and return values will be silently ignored.

For example:

client.request('/_uuids', {count: 2}, function (er, data) {
  if (er) {
    // an error occurred.  Attempt to handle it or rethrow, or whatever.
  } else {
    // data is the result of the request.
  }
})

couchdb.toJSON(data)

Identical to JSON.stringify(), except that function values will be converted to strings like this:

couchdb.toJSON({
  foo: 'bar',
  fn: function(a, b) {
    p(a, b);
  }
})
// => {"foo":"bar","fn":"function (a, b) {\n    p(a, b);\n  }"}

node-couchdb uses this function everywhere for JSON serialization, this makes it convenient to embed functions.

couchdb.toQuery(query)

Identical to querystring.stringify(), except that boolean values will be converted to "true" / "false" strings like this:

couchdb.toQuery({
  include_docs: true
})
// => include_docs=true

node-couchdb uses this function everywhere for query serialization, this helps since couchdb expects boolean values in this format.

couchdb.toAttachment(file, cb)

Takes the path of a file and callback receives a JS object suitable for inline document attachment:

couchdb
  .toAttachment(__filename, function(er, r) {
    if (er) throw new Error(JSON.stringify(er));
    // r => {"content_type":"text/javascript","data":"dmFyCiAgs...="}
  });

Check lib/dep/mime.js for a list of recognized file types.

couchdb.createClient([port, host, user, pass, maxListeners, secure])

Creates a new couchdb.Client for a given port (default: 5984) and host (default: 'localhost'). This client will queue all requests that are send through it, so ordering of requests is always guaranteed. Use multiple clients for parallel operations.

If the optional user and pass arguments are supplied, all requests will be made with HTTP Basic Authorization

If the optional maxListeners is supplied - module uses emitter.setMaxListeners method. It may be useful if you use many couchdb requests and don't want to see warnings. Default Node.js value for this == 11 listeners; if maxListeners == 0 then warnings are off.

If the optional secure is supplied as true, then the https transport is used. Note that https is usually serviced on port 443. This is useful when using cloud-based CouchDB services such as Cloudant where their API is hosted on a https platform e.g.

  client = couchdb.createClient(443, 'username.cloudant.com','username','password',0,true),

client.host

The host this client is connecting to. READ-ONLY property

client.port

The port this client is connecting to. READ-ONLY property

client.request(path, [query], cb)

Sends a GET request with a given path and query. Callback receives a result object. Example:

client.request('/_uuids', {count: 2})

client.request(method, [path, query])

Sends a request with a given method, path and query. Callback receives a result object. Example:

client.request('get', '/_uuids', {count: 2})

client.request(options, cb)

Sends a request using the given options and callback receives a result object. Available options are:

  • method: The HTTP method (default: 'GET')
  • path: The request path (default: '/')
  • headers: Additional http headers to send (default: {})
  • data: A JS object or string to send as the request body (default: '')
  • query: The query options to use (default: {}).
  • requestEncoding: The encoding to use for sending the request (default: 'utf8')
  • responseEncoding: The encoding to use for sending the request. If set to 'binary', the response is emitted as a string instead of an object and the full option is ignored. (default: 'utf8')
  • full: By default the callback receives the parsed JSON as a JS object. If full is set to true, a {headers: ..., json: ...} object is yielded instead. (default: false)

Example:

client.request({
  path: '/_uuids',
  query: {count: 5},
  full: true
}, callback);

client.allDbs()

Wrapper for GET /_all_dbs.

client.config()

Wrapper for GET /_config.

client.uuids([count])

Wrapper for GET /_uuids. count is the number of uuid's you would like CouchDB to generate for you.

client.replicate(source, target, [options])

Wrapper for POST /_replicate. source and target are references to the databases you want to synchronize, options can include additional keys such as {create_target:true}.

client.stats([group, key])

Wrapper for GET /_stats. group and key can be used to limit the stats to fetch.

client.activeTasks()

Wrapper for GET /_active_tasks.

client.db(name)

Creates a new couchdb.Db instance for a database with the given name.

db.name

The name of the db this instance is tied to. READ-ONLY property

db.client

A reference to the couchdb.Client this instance is tied to. READ-ONLY property

db.request(options)

Same as client.request, but the path option gets automatically prefixed by '/db-name'.

db.exists(cb)

Callback called with a boolean indicating whether this db exists or not.

db.info(cb)

Wrapper for GET /db-name.

db.create(cb)

Wrapper for PUT /db-name.

db.remove()

Wrapper for DELETE /db-name.

db.getDoc(id, [rev], [attachments])

Wrapper for GET /db-name/doc-id[?rev=][&attachments=]. Fetches a document with a given id and optional rev and/or attachments from the database.

db.saveDoc(id, doc)

Wrapper for PUT /db-name/doc-id. Saves a json doc with a given id.

db.saveDoc(doc)

Same as the above, but the id can either a property of doc, or omitted to let CouchDB generate a uuid for this new document.

db.removeDoc(id, rev)

Deletes document id with rev from the db.

db.copyDoc(srcId, destId, [destRev])

Copies document srcId to destId. If destId already exists, you need to supply destRev to overwrite it.

db.bulkDocs(data)

Wrapper for POST /db-name/_bulk_docs.

db.saveDesign(design, doc)

A convenience wrapper for saveDoc() that prefixes the document id with '_design/'+design. Useful for storing views like this:

db
  .saveDesign('my-design', {
    views: {
      "my-view": {
        map: function() {
          emit(null, null)
        }
      }
    }
  })

db.saveAttachment(file, docId, options)

Attaches a file to a given docId. Available options:

  • name: The name of the attachment. (default: path.basename(file))
  • contentType: The content type to associate with this attachment (default: see lib/dep/mime.js)
  • rev: If the docId already exists, you have to supply its current revision.

db.removeAttachment(docId, attachmentId, docRev)

Delete attachment attachmentId from doc docId with docRev.

db.getAttachment(docId, attachmentId, cb)

Loads the attachment attachmentId from docId. The callback receivesthe binary content of the attachment. There is no streaming, don't use this with large files.

db.allDocs(query)

Wrapper for GET /db-name/_all_docs. query allows to specify options for this view.

db.allDocsBySeq(query)

Wrapper for GET /db-name/_all_docs_by_seq.

Replaced by GET /db-name/_changes as of CouchDB 0.11. Consider using db.changes or db.changesStream.

db.compact([design])

Wrapper for POST /db-name/_compact/design-name. design provides the name of the design to invoke compact for, otherwise the whole db is used.

db.tempView(data, query)

Wrapper for POST /db-name/_temp_view.

db.viewCleanup(data, query)

Wrapper for POST /db-name/_view_cleanup.

db.view(design, view, [query], [cb])

Wrapper for GET /db-name/_design/design-name/_view/view-name. Fetches all documents for the given design and view with the specified query options.

db.list(design, list, view, [query], [cb])

Wrapper for GET /db-name/_design/design-name/_list/list-name/view-name. Fetches all documents for the given design and view with the specified query options.

db.changes([query])

Wrapper for GET /db-name/_changes. This can be used for long-polling or one-time retrieval from the changes feed. If you want to get a continuous stream of changes, use the db.changesStream() function instead.

db.changesStream([query])

Returns an events.EventEmitter stream that emits the following events:

  • data(change): Emitted for each change line in the stream. The change parameter holds the change object.
  • heartbeat: Emitted for each heartbeat send by CouchDB, no need to check this for most stuff.
  • end(hadError): Emitted if the stream ends. This should not happen unless you manually invoke stream.close().

See the CouchDB docs for available query parameters.

Important: This function uses its own http client for making requests, so unlike all other functions it does not go through the internal request queue.

Todo

  • http status, message and parsed body for errors
  • db.saveAttachment(file, docId, options) take file descriptor
  • Implement Authentication

Limitations

  • Streaming attachments is not supported at this point (patches welcome)
  • Etags are only available via client.request({full: true})

node-couchdb's People

Contributors

0xdb avatar anodos avatar cskr avatar ctavan avatar felixge avatar glynnbird avatar idmillington avatar isaacs avatar jason-cooke avatar jchris avatar jhs avatar langalex avatar mandric avatar mcoolin avatar mikeal avatar nick avatar norlin avatar pimvdb avatar privman avatar redlever avatar robbywalker avatar timemachine3030 avatar zdzolton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-couchdb's Issues

Library may incorrectly return error when error is a key in data

Just come across an issue where you want to store the error variable in your data but when fetching the library believes it is an actual error. For example

db.saveDoc("1", {"error":"my error data" function(err, ok) {
db.getDoc("1", function(err, doc) {
sys.puts(err);
});
});

I know it is on your todo list to look at the http codes but as a quick fix you can change...

"if ('error' in json) {"

...to...

"if ('error' in json && res.statusCode > 299) {"

(line 173 in my copy)

saveDoc(doc, callback) does not work

Hi felixge and team, great work! I found what I expect to be a small bug.

When I try to use db.saveDoc without specifying the document id (e.g. db.saveDoc(doc, callback)), the callback function is given this error:

{"error":"bad_content_type","reason":"Content-Type must be application/json"}

If I choose and specify an id (e.g. db.saveDoc(id, doc, callback)), everything works. Last time I tried was today, using commit 2b74e56 . Thanks!

Giacecco

Warning: possible EventEmitter memory leak detected.

(node) warning: possible EventEmitter memory leak detected. 11 listeners added.
Use emitter.setMaxListeners() to increase limit.
Trace: 
    at Client.<anonymous> (events.js:139:15)
    at [object Object]._queueRequest (/node_modules/felix-couchdb/lib/couchdb.js:158:16)
    at [object Object].request (/node_modules/felix-couchdb/lib/couchdb.js:269:15)
    at [object Object].request (/node_modules/felix-couchdb/lib/couchdb.js:341:24)
    at [object Object].view (/node_modules/felix-couchdb/lib/couchdb.js:557:17)

I am iterating over some objects and are sending a request to Couch for everyone of it. I think this causes the warning. Anything I can do to prevent it?

removeDoc doesn't work

The removeDoc method calls DELETE /id?rev=rev but it looks like it should call DELETE /db/id?rev=rev

using cloudant for storage

i am using cloudant for storage. missing feature: https requests using httpClient in node-couchdb?

i would want to do something on the lines of :

var express   = require('express'),
    couchdb   = require('couchdb');

var app    = express.createServer(),
    couch  = couchdb.createClient(443, "username.cloudant.com", "username", "password");

var db  = couch.db('database');
app.get('/', function(req, res) {
        db.getDoc('doc', function(err, doc) {
            res.send(doc);
        })
});

app.listen(3000);

documentation issue

client.uuids([count]) is not complete, it should read

client.uuids([count], cb)

and count's default value is 1.

Basic Example from Readme throwing errors from promise lib

rinzler:node sebs$ node test.js

/Users/sebs/projects/discogsimport/node/node_modules/couchdb/node_modules/promised-io/lib/promise.js:215
throw error;
^
[object Object]
rinzler:node sebs$

I am using the latest couchbase the latest module from npm. I have several issues with that.

  1. There seems to be a mistake in error handling inside the NPM module: As a couchbase user I am not willing to debug errors in promises. I am not even capable of it.
  2. This is a basic example, and IF couchbase single IS a valid db for this module, I expect as a minimum the example from the readme to work.

my script

var
sys = require('util'),
couchdb = require('couchdb'),
client = couchdb.createClient(5984, 'localhost'),
db = client.db('releases');

db
.saveDoc('my-doc', {awesome: 'couch fun'}, function(er, ok) {
if (er) throw new Error(JSON.stringify(er));
sys.puts('Saved my first doc to the couch!');
});

releases DB exist, db is writable from futon without permission stuff

my tree of ods i use
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
└─┬ [email protected]
└── [email protected]

Tutorial doesn't work.

Please update it. The require statement doesn't find the library. Even after it is corrected, the script only ever does the PUT request, and doesn't run either of the puts calls. The output looks like this:

deprecation warning: process.mixin will be removed from node-core future releases.
Client. (http:393:14)
node.js:811:9

optional 'query' argument is not optional

The documentation lists query as an optional argument to db.view(), but it really isn't. The function will silently fail if called like this.

db.view(design, view, function () {...})

Everything works great if you remember to include the query argument:

db.view(design, view, {}, function () {...})

Apart from the mismatch between documentation and reality, I think it would be a good idea to throw an exception from _queueRequest if the callback is undefined. IMHO there isn't really any situations where it is usefull to not handle the response.

(oh - and by the way, great library! Sorry my first words of praise form of a bug report... I really like your work on this!)

npm version is outdated

Any idea when the npm version will be updated to fix the setMaxListeners bug that occurs with v0.10?

db.changesStream crashes in node 0.4.12

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.

removeDoc closes socket?

Trying to delete a load of docs in a loop, the first works but then it throws:

db.request('/_design/my-view', query, function(err, data) {
    data.rows.forEach(function (e) {
        db.removeDoc(e.doc._id, e.doc._rev, console.log);
    });
});

output:

null { ok: true,
  id: '90a8b799188655eb73656f01818a91fe',
  rev: '2-79f3763a77a0749f6290f6db2733d50f' }

events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
    Error: socket hang up
        at createHangUpError (http.js:1263:15)
        at Socket.socketOnEnd [as onend] (http.js:1351:23)
        at TCP.onread (net.js:418:26)

Error: socket hang up

I am seeing this both in my own project and when running node test/test-changes.js

node test/test-changes.js 

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
            ^
Error: socket hang up
    at createHangUpError (http.js:1107:15)
    at Socket.<anonymous> (http.js:1210:27)
    at Socket.emit (events.js:88:20)
    at Array.0 (net.js:320:10)
    at EventEmitter._tickCallback (node.js:192:40)

db.streamChanges() seems broke

Calling db.streamChanges() generates a URL including this:
/_changes?feed=%22continuous%22

When it should be this:
/_changes?feed=continuous

Cannot read property '0' of undefined on node v 0.12

We sometimes get this error on node v 0.12:

TypeError: Cannot read property '0' of undefined
    at IncomingMessage.<anonymous> (/home/vagrant/keli/node_modules/felix-couchdb/lib/couchdb.js:220:47)
    at IncomingMessage.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11) [TypeError: Cannot read property '0' of undefined]

The exception points to this line in couchdb.js:

          httpAgent.sockets[host + ':' + port][0].emit("agentRemove");

From what I can tell the sockets array has a different format in this version of node. Looking at the state of httpAgent.sockets just before the exception I see the format is actually host + ':' + port + '::'. There is also a new (since node v0.10) function on httpAgent called getName(...) that is probably better to use than a manually built string. Just the same, I've fixed the issue for us by changing that line to this:

          var socketKey = (httpAgent.getName && httpAgent.getName({host: host, port: port, maxSockets: 1})) || (host + ':' + port + '::');
          (httpAgent.sockets[socketKey] || httpAgent.sockets[host + ':' + port])[0].emit("agentRemove");

This is a very careful fix as it tries to maintain backward compatibility. If you think this fix makes sense just let me know and I'll submit a pull request.
Thanks!

HTTP error detection

The code (near line 232) that detects CouchDB HTTP errors seems dangerous to me:

          if ('error' in json) {
            cbFired = true;
            return cb && cb(json);
          }

If I save a document with an 'error' attribute, node-couchdb will raise an error every time I fetch it. You should rely on the HTTP status code instead.

TypeError in require('couchdb').createClient(5984, 'localhost')

npm install couchdb
$ node
> couchdb = require('couchdb')
{ createClient: [Function],
  parseBody: [Function],
  Database: [Function],
  USER_PREFIX: 'org.couchdb.user:' }
> client = couchdb.createClient(5984, 'localhost')
TypeError: Object.getOwnPropertyNames called on non-object
    at getOwnPropertyNames (native)
    at trait (/home/anup/.node_libraries/.npm/traits/0.4.0/package/lib/traits.js:259:13)
    at Trait (/home/anup/.node_libraries/.npm/traits/0.4.0/package/lib/traits.js:647:12)
    at Object.createClient (/home/anup/.node_libraries/.npm/couchdb/0.1.0/package/lib/couchdb.js:25:59)
    at [object Context]:1:18
    at Interface. (repl.js:144:22)
    at Interface.emit (events.js:42:17)
    at Interface._onLine (readline.js:132:10)
    at Interface._line (readline.js:387:8)
    at Interface._ttyWrite (readline.js:564:14)
> 

please help
can't get couchdb to work AT ALL
http://localhost:5984 returns

{"couchdb":"Welcome","version":"1.0.1"}

Correctly encode document IDs

(Thought I submitted this already but don't see it.)

Fetching documents with special characters does not work, particularly when a document ID has / in it. This is because node-couchdb simply forwards the document ID into httpClient, and the server will think it is a request for an attachment.

I will submit a patch however I am unsure which solution is best.

  1. In couchClient._queueRequest(), encode the path before making the request, i.e. encodeURIComponent(options.path)
  2. Find every query which is definitely not for an attachment and encodeURIComponent() at that point. Candidates:
    • Client.prototype.db's couchdb.request
    • Db.prototype.getDoc
    • Db.prototype.saveDoc
    • Db.prototype.removeDoc
    • Db.prototype.copyDoc (srcId and possibly destId, need to check)
    • Db.prototype.saveAttachment
    • Db.prototype.removeAttachment
    • Db.prototype.getAttachment
    • Db.prototype.view
  3. Something more advanced such as an option to _queueRequest to encode the path, default=true. Then getAttachment can set it to false

I think choice 1 would break getAttachment() but choice 2 is a comparatively larger patch. What do you think? Thanks.

Two NPM packages called couchdb?

Howdy,

While trying to get my node server and app set up I noticed that there seems to be two packages called "couchdb."

Note my output from NPM:
$ npm list couchdb
npm info it worked if it ends with ok
npm info using [email protected]
[email protected] =nathan remote
[email protected] =nathan latest remote
[email protected] =nathan active installed
[email protected] =samuraijack latest remote
npm ok

Also note the user is not yours.

I know your couchdb package is at version 1.0.0. Meanwhile I believe version 0.1.0 is the latest from this project:
https://github.com/nrstott/couchdb-commonjs/blob/master/package.json

Perhaps one you guys could change your package name...? Anyways, just trying to clear things up!

Cheers,

Zach

toQuery doesn't like arrays

couchdb.toQuery({ keys: ["a", "b"] });

returns:

keys=a%2Cb

It seems like it's just joining the elements. CouchDB doesn't like this in case of using { keys: [...] } in a query. The array should be converted to JSON and then be encoded into the URL. At least, that's what I understand from the docs.

I'd very much like to see this working as it is currently not possible to use the keys query option. Thanks for considering.

Querystring parameters for views

I ran into a simple issue regarding querystring encoding. Example:

db.view('designDoc', 'viewName', {'key': 'Something'}, function() {
    sys.p(arguments);
});

This results in the following output:
someDb/_design/designDoc/_view/viewName?key=Something

The problem is that the value Something should be surrounded by quotes (apparently double):
..?key="Something"

error thrown

hello,

sometimes when accessing a view the following error is thrown:

{ message: 'Operation not permitted'
, stack: [Getter/Setter]
}

it's thrown by line 135 of couchdb.js:

    if (hadError && !cbFired) cb && cb(new Error(reason));

can you explain what that means?

setBodyEncoding does not work in nodejs v0.1.96

There is a setBodyEncoding call on line 156 which keeps giving me errors. The error specifically is: "setBodyEncoding has been renamed to setEncoding, please update your code."

If this is changed, then I no longer get errors.

saveDoc is having issues parsing certain JSON

Here's the stack of the error when I try to use saveDoc

Error: {"stack":"Error: invalid json: undefined Unexpected token ILLEGAL\n at IncomingMessage. (~/node_modules/felix-couchdb/lib/couchdb.js:185:29)\n at IncomingMessage.emit (events.js:81:20)\n at HTTPParser.onMessageComplete (http.js:133:23)\n at Client.onData as ondata\n at Client._onReadable (net.js:677:27)\n at IOWatcher.onReadable as callback","message":"invalid json: undefined Unexpected token ILLEGAL"}

Not available on NPM!

I remember installing node-couchdb from NPM. However, it looks like someone else has become the maintainer of 'couchdb' module in NPM registry and that module doesn't even work.

Are you not maintaining the module in NPM anymore?

Can't creatClient. Fails everytime!

peter@ubuntu:~$ node

couchdb = require('couchdb')
{ createClient: [Function],
parseBody: [Function],
Database: [Function],
USER_PREFIX: 'org.couchdb.user:' }
client = couchdb.createClient(5984, 'localhost')
TypeError: Object.getOwnPropertyNames called on non-object
at getOwnPropertyNames (native)
at trait (/usr/local/lib/node/.npm/traits/0.4.0/package/lib/traits.js:259:13)
at Trait (/usr/local/lib/node/.npm/traits/0.4.0/package/lib/traits.js:647:12)
at Object.createClient (/usr/local/lib/node/.npm/couchdb/0.1.0/package/lib/couchdb.js:25:59)
at [object Context]:1:18
at Interface. (repl.js:144:22)
at Interface.emit (events.js:42:17)
at Interface._onLine (readline.js:132:10)
at Interface._line (readline.js:387:8)
at Interface._ttyWrite (readline.js:564:14)

cb firing multiple times

Near line 178, this code doesn't set cbFired to true:

onError = function(reason) {
        if (!cbFired && typeof cb === 'function') {
          cb(new Error(reason));
        }
      },
      onClose = function() {
        if (!cbFired && typeof cb === 'function') {
          cb();
        }
      },

If a TCP error occurs, the callback is called twice.

new version of nodejs produces warning and errors

hi,

using version 0.1.90 of nodejs you can see this warning:

Warning: ClientRequest.prototype.close has been renamed to end()

additionally the new version produces some errors. just run the tests and you will see.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.