From a6ba60a5c42dbca5ecf70c60ac183a004c4b84cd Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Sun, 8 May 2016 22:22:46 +0200 Subject: [PATCH] handle errors when closing --- src/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 514791b..304d6cc 100644 --- a/src/index.js +++ b/src/index.js @@ -380,7 +380,13 @@ function Swarm (peerInfo) { async.each( Object.keys(this.transports), - (key, cb) => this.transports[key].close(cb), + (key, cb) => { + // avoid unhandled error messages + this.transports[key].once('error', (err) => { + console.log('got error', err) + }) + this.transports[key].close(cb) + }, callback ) }