[Pkg-javascript-commits] [node-leveldown] 143/492: set maxListeners to Infinity to prevent warnings when using deferred open. fixes #47
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:13:53 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.
commit bae8af68e14216a5bfefe11e201ef38889bc5ae8
Author: Julian Gruber <julian at juliangruber.com>
Date: Tue Jan 1 10:03:35 2013 +0100
set maxListeners to Infinity to prevent warnings when using deferred open. fixes #47
---
lib/levelup.js | 2 ++
test/deferred-open-test.js | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/lib/levelup.js b/lib/levelup.js
index 74ad8d8..8bca9d1 100644
--- a/lib/levelup.js
+++ b/lib/levelup.js
@@ -47,6 +47,8 @@ var bridge = require('bindings')('levelup.node')
function LevelUP (location, options) {
this.__proto__.__proto__ = EventEmitter.prototype
EventEmitter.call(this)
+ this.setMaxListeners(Infinity)
+
this._options = extend(extend({}, defaultOptions), options)
this._location = location
this._status = 'new'
diff --git a/test/deferred-open-test.js b/test/deferred-open-test.js
index 98f05c5..e6bd34b 100644
--- a/test/deferred-open-test.js
+++ b/test/deferred-open-test.js
@@ -95,4 +95,27 @@ buster.testCase('Deferred open()', {
refute(db.isOpen())
refute(db.isClosed())
}
+
+
+ , 'maxListeners warning': function (done) {
+ var location = common.nextLocation()
+ // 1) open database without callback, opens in worker thread
+ , db = levelup(location, { createIfMissing: true, errorIfExists: true, encoding: 'utf8' })
+
+ this.closeableDatabases.push(db)
+ this.cleanupDirs.push(location)
+
+ // 2) provoke an EventEmitter maxListeners warning
+ var toPut = 11
+
+ for (var i = 0; i < toPut; i++) {
+ db.put('some', 'string', function (err) {
+ refute(err)
+
+ if (!--toPut) {
+ done()
+ }
+ })
+ }
+ }
})
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git
More information about the Pkg-javascript-commits
mailing list