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

How to remove a torrent for the client? #1101

Closed
catchstar opened this issue Apr 12, 2017 · 6 comments
Closed

How to remove a torrent for the client? #1101

catchstar opened this issue Apr 12, 2017 · 6 comments

Comments

@catchstar
Copy link

@catchstar catchstar commented Apr 12, 2017

My code:

const WebTorrent = require('webtorrent')
let client = new WebTorrent();
let torrentId = 'magnet:?xt=urn:btih:1E717B83DFDC69339F260E7BAB85E8C9D87B835A';

client.add(torrentId);

client.on('torrent', function (torrent) {
    console.log(torrent)
    
   // occur an error: No torrent with id magnet
    client.remove(torrentId);
});

but if change below like that, it will be ok:

client.on('torrent', function (torrent) {
    console.log(torrent)
    
   // remove right
   setTimeout(() => {
       client.remove(torrentId);
   }, 0)
});

i'm confused by this problem.
please help me to solve the problem.Thanks a lot.

@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented Apr 12, 2017

Weird because the torrent is being added before the torrent callback is emitted: https://github.com/feross/webtorrent/blob/master/index.js#L261

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Apr 13, 2017

@catchstar I ran your code and could not reproduce the issue with the latest version of WebTorrent.

What version of webtorrent do you have installed? Are you possibly calling client.remove() or torrent.destroy() anywhere else in your program? Since that could cause this issue.

@feross feross closed this Apr 13, 2017
@catchstar

This comment has been minimized.

Copy link
Author

@catchstar catchstar commented Apr 13, 2017

@feross my vps could reproduce the issue but i can't login in right now.Because i receive a shutdown ticket from lindode support which say my program has a copyright-infringing question.
When i solve the linode problem, i will check the webtorrent version. orz..:(

@catchstar

This comment has been minimized.

Copy link
Author

@catchstar catchstar commented Apr 13, 2017

@feross @DiegoRBaquero Hello, i reproduce the problem. Here my code:

const WebTorrent = require('webtorrent')
let client = new WebTorrent();

// the torrentId is different with above
let torrentId = '08BC48D2EF4887EAEBE759CA31736B6A7C6CABFB';
client.add(torrentId);

client.on('torrent', function (torrent) {
    console.log(torrent)

   // occur an TypeError: Cannot read property '_debugId' of null
   client.remove(torrentId);
});

webtorrent version : 0.98.16
NodeJS version: v6.10.2

i try this code on two vps and occur error either.

@catchstar

This comment has been minimized.

Copy link
Author

@catchstar catchstar commented Apr 13, 2017

@feross @DiegoRBaquero
i debug the program and found after destory the torrent and reset the self.client = null
https://github.com/feross/webtorrent/blob/master/lib/torrent.js#L708

and program will still run by the wire.request callback function
https://github.com/feross/webtorrent/blob/master/lib/torrent.js#L1500

it makes me feel so weird.

feross added a commit that referenced this issue Apr 13, 2017
Fixes: #1101
josephfrazier added a commit that referenced this issue Apr 13, 2017
Fixes: #1100
Fixes: #1101
@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 3, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.