Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

"The libp2p node is not started yet" error during discovery #874

Closed
pgte opened this issue May 31, 2017 · 10 comments
Closed

"The libp2p node is not started yet" error during discovery #874

pgte opened this issue May 31, 2017 · 10 comments

Comments

@pgte
Copy link
Contributor

pgte commented May 31, 2017

Printed message during the tests:

assert.js:81
  throw new assert.AssertionError({
  ^
AssertionError: The libp2p node is not started yet
    at Node.dial (/Users/pedroteixeira/projects/ipfs/ipfs-level/node_modules/libp2p/src/index.js:239:5)
    at Node.self._libp2pNode.on (/Users/pedroteixeira/projects/ipfs/ipfs-level/node_modules/ipfs/src/core/components/libp2p.js:29:30)
    at emitOne (events.js:96:13)
    at Node.emit (events.js:188:7)
    at EventEmitter.discovery.on (/Users/pedroteixeira/projects/ipfs/ipfs-level/node_modules/libp2p/src/index.js:71:49)
    at emitOne (events.js:96:13)
    at EventEmitter.emit (events.js:188:7)
    at WebRTCStar._peerDiscovered (/Users/pedroteixeira/projects/ipfs/ipfs-level/node_modules/libp2p-webrtc-star/src/index.js:241:20)
    at Socket.Emitter.emit (/Users/pedroteixeira/projects/ipfs/ipfs-level/node_modules/libp2p-webrtc-star/node_modules/component-emitter/index.js:133:20)
    at Socket.onevent (/Users/pedroteixeira/projects/ipfs/ipfs-level/node_modules/libp2p-webrtc-star/node_modules/socket.io-client/lib/socket.js:267:10)

Looks like there may be a race condition here, since self.isOnline() returns true here, but the libp2p isOn() assertion fails here.

@pgte
Copy link
Contributor Author

pgte commented May 31, 2017

I think I found it:

return Boolean(self._bitswap && self._libp2pNode)

@pgte
Copy link
Contributor Author

pgte commented May 31, 2017

Also, and since this is internal, instead asserting the online status, it should queue the operations for when the node is online (like many database clients do).

In this case, the .dial() is being called because we discovered a peer. IMO, we should not ignore this event. Instead, we should queue until every networking component (bitswap and libp2p I guess) is considered to be online.

@pgte
Copy link
Contributor Author

pgte commented May 31, 2017

Can provide a PR, but would like some guidance before :)

@daviddias
Copy link
Member

daviddias commented Jun 3, 2017

Interesting, that if was added specifically to avoid that race condition. I agree with you, all of these should be queued up. The queueing, however, should not let two dials to be unlocked at the same time, which will confuse libp2p-swarm until it becomes a state machine. Go for it and submit a PR with this detail in mind :)

@pgte
Copy link
Contributor Author

pgte commented Jun 3, 2017

ok, I'm onto this..

@daviddias
Copy link
Member

@pgte did you get a fix for this?

@pgte
Copy link
Contributor Author

pgte commented Jun 16, 2017

@diasdavid not yet, working around this. Have a local fix, but still lacking some tests.
Will work on a PR for this next week..

@daviddias daviddias added the status/deferred Conscious decision to pause or backlog label Jul 3, 2017
@daviddias
Copy link
Member

@pgte this is now fixed, right?

@pgte
Copy link
Contributor Author

pgte commented Jul 9, 2017 via email

@daviddias
Copy link
Member

woot ! thanks @pgte :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants