Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeDoc closes socket? #48

Open
ghost opened this issue Sep 28, 2012 · 4 comments
Open

removeDoc closes socket? #48

ghost opened this issue Sep 28, 2012 · 4 comments

Comments

@ghost
Copy link

ghost commented Sep 28, 2012

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)
@norlin
Copy link
Contributor

norlin commented Sep 29, 2012

What are in "query" variable?

@ghost
Copy link
Author

ghost commented Oct 1, 2012

The full code is here:

var client = couchdb.createClient(config.couch.port, config.couch.host);
var db = client.db(config.couch.database);

var query = {};
query.key = "bar";
query.include_docs = true;
db.request('/_design/foo/_view/docsByType', query, function(err, data) {
  data.rows.forEach(function (bar) {
    db.removeDoc(bar.doc._id, bar.doc._rev, console.log);
    console.log(bar.id, bar.doc._rev);
  });
//console.log(data.rows.length);
});

It's not the db.request that's failing, by query shouldn't matter. If I just console.log(bar.doc._id) and bar.doc._rev I get all the records logged out correctly.

@norlin
Copy link
Contributor

norlin commented Oct 1, 2012

Huh, I'm cannot reproduce that. In my case, all docs removed successfully. (node.js 0.8.6 && CouchDB 1.2.0, with default settings)

p.s. oops, accidentally closed task

@norlin norlin closed this as completed Oct 1, 2012
@norlin norlin reopened this Oct 1, 2012
@ghost
Copy link
Author

ghost commented Oct 1, 2012

I'm running node 0.8.9 and couch 1.2.0 on localhost.

Hmmm. There's literally nothing other than the config and couch module requires in that file. If I copy the first two lines and put them into the loop just before removeDoc it works (because it's re-establishing a client).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant