Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the noPeers event expected behavior? #1622

Open
KingZee opened this issue May 2, 2019 · 4 comments
Open

What is the noPeers event expected behavior? #1622

KingZee opened this issue May 2, 2019 · 4 comments

Comments

@KingZee
Copy link

@KingZee KingZee commented May 2, 2019

What version of WebTorrent?
@latest
What operating system and Node.js version?
@latest

Reproductible snippet :

const wt = require('webtorrent');
var sintel = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F';
var client = new wt();
var tor = client.add(sintel);
tor.on('noPeers', a => console.log('No '+a+' peers'));

Since the 'Sintel' torrent is a very healthy torrent with many active trackers and peers sharing it, I don't understand what would be the use of 'noPeers' if it's called on every announce with no peers.

Shouldn't the event only be called on edge cases when there are no active peers to continue download of the file, or on a very 'unhealthy' torrent with no peers at all to fetch metadata? This behavior makes the event almost useless in every case, unless I'm understanding it wrong. Thanks!

@KingZee KingZee changed the title What is the noPeers event expected behaviour? What is the noPeers event expected behavior? May 2, 2019
@stale

This comment has been minimized.

Copy link

@stale stale bot commented Jul 31, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Jul 31, 2019
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jul 31, 2019

I agree that the event doesn't seem very easy to work with. But wouldn't a healthy torrent never have an announce with no peers?

@stale stale bot removed the stale label Jul 31, 2019
@stale stale bot removed the stale label Jul 31, 2019
@KingZee

This comment has been minimized.

Copy link
Author

@KingZee KingZee commented Aug 1, 2019

Like I mentioned, the snippet above is a minimal reproductible example. I used the "Sintel" torrent present on the webtorrent.io homepage. The noPeers event is called a few times every time it's added.

@no-response no-response bot removed the need more info label Aug 1, 2019
@alxhotel

This comment has been minimized.

Copy link
Member

@alxhotel alxhotel commented Aug 1, 2019

I think one of the reasons why this might be happening is because at the start of downloading a torrent, when there are no peers, the update event of the bittorrent-racker is triggered here, before the event peer is emitted here.

When the update event is triggered, it checks for the number of connected peers here, before getting the first peer. Therefore, emitting the noPeers event before actually getting the peers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.