ENFILE Too many different file openings throughout the system. Please note that any number of linked channels counts as just one file open; See Related Channels. This error never occurs on GNU / Hurd systems.
Using this one promiseDebouncer, I turned up the call putand pressed it.
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)
source
share