mafintosh / torrent-stream

The low level streaming torrent engine that peerflix uses
MIT License
1.94k stars 227 forks source link

"cb() is not a function" on engine.remove #143

Closed giacomocerquone closed 8 years ago

giacomocerquone commented 8 years ago

Hello, so I'm trying to call engine.remove() once the engine is created and it's downloading but it won't work. I tried to call it with:

engine.remove()

and it returns:

node_modules\torrent-stream\index.js:718
        cb()
        ^

TypeError: cb is not a function
    at FSReqWrap.oncomplete (C:\Users\...\node_modules\torrent-stream\index.js:718:9)

I tried also

engine.remove([], function() {
    console.log("removed");
});

or

engine.remove(function() {
    console.log("removed");
});

and nothing happens, like I've never called this method. Is it possible that something is wrong there in the library? Thank you :)

mafintosh commented 8 years ago

Did you fix this? :)

giacomocerquone commented 8 years ago

I don't think it was actually a problem of the library but a strange behaviour. In fact calling engine.remove the file were deleted but the swarm continued to download stuff (and I didn't even know where this stuff were downloaded). So I fixed this calling engine.destroy() for first and engine.remove() right after.

PS = and the callback should be specified that is not facultative, if you don't put it, the error specified above will return.

mafintosh commented 8 years ago

Oh okay. I guess .remove should call .destroy for you. If you wanna PR that I'd merge it.

giacomocerquone commented 8 years ago

Ok, give me some time please because I would like also to check that callback and make it an optional paramater if it is ok for you.

mafintosh commented 8 years ago

Sounds good

On Sun, Nov 8, 2015 at 2:34 AM Giacomo Cerquone notifications@github.com wrote:

Ok, give me some time please because I would like also to check that callback and make it an optional paramater if it is ok for you.

— Reply to this email directly or view it on GitHub https://github.com/mafintosh/torrent-stream/issues/143#issuecomment-154802332 .