javascript - 错误 : connect ENFILE 127. 0.0.1:5984 - 本地(未定义:未定义)

标签 javascript node.js couchdb pouchdb

我一直收到这个 pouchDB 错误,我不知道这是怎么回事。

Error: connect ENFILE 127.0.0.1:5984 - Local (undefined:undefined)
    at onError (/Users/thomas/Desktop/rain/node_modules/pouchdb/lib/deps/ajax/ajaxCore.js:53:18)
    at Request._callback (/Users/thomas/Desktop/rain/node_modules/pouchdb/lib/deps/ajax/ajaxCore.js:103:14)
    at self.callback (/Users/thomas/Desktop/rain/node_modules/request/request.js:198:22)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)
    at Request.onRequestError (/Users/thomas/Desktop/rain/node_modules/request/request.js:867:8)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at Socket.socketErrorListener (_http_client.js:265:9)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1253:8)
    at doNTCallback2 (node.js:450:9)
    at process._tickCallback (node.js:364:17)

最佳答案

ENFILE There are too many distinct file openings in the entire system. Note that any number of linked channels count as just one file opening; see Linked Channels. This error never occurs on GNU/Hurd systems.

使用这个 promiseDebouncer 我包装了 put 调用并限制了它。

function promiseDebounce(fn, delay, count) {
  var working = 0, queue = [];
  function work() {
    if ((queue.length === 0) || (working === count)) return;
    working++;
    Promise.delay(delay).tap(function () { working--; }).then(work);
    var next = queue.shift();
    next[2](fn.apply(next[0], next[1]));
  }
  return function debounced() {
    var args = arguments;
    return new Promise(function(resolve){
      queue.push([this, args, resolve]);
      if (working < count) work();
    }.bind(this));
  }
}

let debouncePut = promiseDebounce(db.put, 1000, 100).bind(db)

关于javascript - 错误 : connect ENFILE 127. 0.0.1:5984 - 本地(未定义:未定义),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33644016/

相关文章:

JavaScript 改变了我的 CSS

angularjs - 如何在没有 Nodejs 的情况下从 AngularJS 端保护我的数据库访问

javascript - 如何向 watson 对话响应添加操作?

couchdb - 使用 CouchDB 启动应用程序时出现异常

couchdb - 在 CouchDB 上实现用户评分/收藏夹

mongodb - CouchDB 或 MongoDB 中的哪一个适合我的需求?

javascript - useState 如何迭代数组

javascript - 在 Javascript 中将日期时间字符串转换为时间戳

javascript - HTML 音频对象报告错误的文件持续时间

javascript - 当您使用来自 "ExpressionChangedAfterItHasBeenCheckedError"的信息时,如何避免 "Cannot Read Property of Undefined"或 "@ViewChild"?