Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.js1
-rw-r--r--test/basic.js5
2 files changed, 5 insertions, 1 deletions
diff --git a/index.js b/index.js
index 27f7f48..9c8fa32 100644
--- a/index.js
+++ b/index.js
@@ -91,6 +91,7 @@ function WebTorrent (opts) {
} else process.nextTick(ready)
function ready () {
+ if (self.destroyed) return
self.ready = true
self.emit('ready')
}
diff --git a/test/basic.js b/test/basic.js
index 107fc8a..6310a51 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -99,7 +99,7 @@ test('after client.destroy(), throw on client.add() or client.seed()', function
})
})
-test('after client.destroy(), no "torrent" event should be emitted', function (t) {
+test('after client.destroy(), no "torrent" or "ready" events emitted', function (t) {
t.plan(1)
var client = new WebTorrent({ dht: false, tracker: false })
@@ -109,6 +109,9 @@ test('after client.destroy(), no "torrent" event should be emitted', function (t
client.seed(leavesBook, function () {
t.fail('unexpected "torrent" event (from seed)')
})
+ client.on('ready', function () {
+ t.fail('unexpected "ready" event')
+ })
client.destroy(function () {
t.pass('client destroyed')
})