What version of this package are you using?

[email protected]

[email protected]

What operating system, Node.js, and npm version? OS: Linux Lite 5 (64 bit)

Node.js: 14.15.1

npm: 6.14.8

What happened?

I normally initialised a client by following the docs. Like so:

this.webTorrentClient = new WebTorrentHybrid({tracker: true, dht: true});

However, I simply wanted to switch my torrent to private so that it won't publish to DHT, PEX and LSD. I specifically have a requirement to disable LSD. Again I followed the docs, added opts and put in the private flag like so:

this.webTorrentClient.add(magnetUri, {private: true}, (torrent) => {
        //did my task here
      });

On doing that weirdly I was greeted with this error stating that this particular property doesn't exist in torrent options

Argument of type '{ private: boolean; }' is not assignable to parameter of type 'TorrentOptions'.
  Object literal may only specify known properties, and 'private' does not exist in type 'TorrentOptions'

On facing this error, I initially figured that maybe opts for WebTorrentHybrid are different from WebTorrent but when I fetched the docs they stated that it's exactly the same. I then tried putting private: true in the .seed method instead, but received the same error.

Alternatively I figured, that since I only want LSD to be disabled and digging through the commit history I found that an option to disable LSD has also been added. (With reference to this commit ID here: https://github.com/webtorrent/webtorrent/commit/0ba67b8e8f54d888ba0dd14a6e5f4a18d46e1294). So I tried putting lsd: false in both .add and .seed but again no dice. Same error.

At this point I felt that maybe I am passing opts in the wrong format but on trying other opts. They worked just fine. I tried putting path: '/mnt/drive1/' in both .add and .seed like so:

this.webTorrentClient.add(magnetUri, {path: '/mnt/drive1/'}, (torrent) => {
        //did my task here
      });

And it worked absolutely fine, similarly I tried maxWebConns: 3 and that too worked! For some reason only private and lsd don't seem to be working in my case. Quick google search showed that no one else had a similar problem and I was left confused!

I have been following the official docs from here: https://webtorrent.io/docs

1

There are 1 answers

0
Ankit Panchal On BEST ANSWER

For anyone facing the same issue. I solved the above issue by manually updating the following packages by using these commands:

npm update --save/--save-dev
npm install webtorrent@latest --save-dev
npm install @types/webtorrent@latest --save-dev

I had in my quest to solve this issue, run npm update --save/--save-dev several times. But for some reason these packages hadn't been updated even when there weren't any breaking changes. Realising they were outdated by running npm outdated and then manually updating by using the commands above solved it!