Skip to content

Commit 39b324e

Browse files
Alan Shawhugomrdias
Alan Shaw
authored andcommitted
fix: remove swarm addrs in browser (#435)
New libp2p is strict about providing addrs that you can listen on. https://github.com/libp2p/js-libp2p/blob/83409deaa6773a550d38b77bd486faf8b8b97d29/src/transport-manager.js#L172-L176
1 parent 55543f2 commit 39b324e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

.aegir.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const createServer = require('./src').createServer
44

55
const server = createServer() // using defaults
66
module.exports = {
7-
bundlesize: { maxSize: '920kB' },
7+
bundlesize: { maxSize: '928kB' },
88
karma: {
99
files: [{
1010
pattern: 'test/fixtures/**/*',

src/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ module.exports = ({ type }) => {
88
// from the browser tell remote nodes to listen over WS
99
if (type !== 'proc' && (isBrowser || isWebWorker)) {
1010
swarm = ['/ip4/127.0.0.1/tcp/0/ws']
11+
// from the browser, in process nodes cannot listen on _any_ addrs
12+
} else if (type === 'proc' && (isBrowser || isWebWorker)) {
13+
swarm = []
1114
} else {
1215
swarm = ['/ip4/127.0.0.1/tcp/0']
1316
}

test/create.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ describe('`createController({test: true})` should return daemon with correct con
8080

8181
if ((isBrowser || isWebWorker) && opts.type !== 'proc') {
8282
expect(swarm).to.be.deep.eq(['/ip4/127.0.0.1/tcp/0/ws'])
83+
} else if ((isBrowser || isWebWorker) && opts.type === 'proc') {
84+
expect(swarm).to.be.deep.eq([])
8385
} else {
8486
expect(swarm).to.be.deep.eq(['/ip4/127.0.0.1/tcp/0'])
8587
}

0 commit comments

Comments
 (0)