diff --git a/src/index.js b/src/index.js index 94a243d67b..8c3d225625 100644 --- a/src/index.js +++ b/src/index.js @@ -156,15 +156,15 @@ class Node extends EventEmitter { // so that we can have webrtc-star addrs without adding manually the id const maOld = [] const maNew = [] - this.peerInfo.multiaddrs.forEach((ma) => { + this.peerInfo.multiaddrs.toArray().forEach((ma) => { if (!ma.getPeerId()) { maOld.push(ma) maNew.push(ma.encapsulate('/ipfs/' + this.peerInfo.id.toB58String())) } }) this.peerInfo.multiaddrs.replace(maOld, maNew) - const multiaddrs = this.peerInfo.multiaddrs.toArray() + const multiaddrs = this.peerInfo.multiaddrs.toArray() transports.forEach((transport) => { if (transport.filter(multiaddrs).length > 0) { this.swarm.transport.add( @@ -177,14 +177,6 @@ class Node extends EventEmitter { } }) - // detect which multiaddrs we don't have a transport for and remove them - multiaddrs.forEach((multiaddr) => { - if (!multiaddr.toString().match(/\/p2p-circuit($|\/)/) && - !transports.find((transport) => transport.filter(multiaddr).length > 0)) { - this.peerInfo.multiaddrs.delete(multiaddr) - } - }) - series([ (cb) => this.swarm.listen(cb), (cb) => { @@ -208,6 +200,19 @@ class Node extends EventEmitter { } cb() }, + (cb) => { + // detect which multiaddrs we don't have a transport for and remove them + const multiaddrs = this.peerInfo.multiaddrs.toArray() + transports.forEach((transport) => { + multiaddrs.forEach((multiaddr) => { + if (!multiaddr.toString().match(/\/p2p-circuit($|\/)/) && + !transports.find((transport) => transport.filter(multiaddr).length > 0)) { + this.peerInfo.multiaddrs.delete(multiaddr) + } + }) + }) + cb() + }, (cb) => { this.emit('start') cb() diff --git a/test/nodejs-bundle/multiaddr-trim.js b/test/nodejs-bundle/multiaddr-trim.js index 46cd2d855e..996982b3be 100644 --- a/test/nodejs-bundle/multiaddr-trim.js +++ b/test/nodejs-bundle/multiaddr-trim.js @@ -6,7 +6,7 @@ chai.use(require('dirty-chai')) const expect = chai.expect const createNode = require('./utils').createNode -describe.only('multiaddr trim', () => { +describe('multiaddr trim', () => { let node it('can create a test node with an irrelevant multiaddr', (done) => { createNode(