mafintosh / torrent-stream

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

Imposible to catch an error #201

Open ceritium opened 4 years ago

ceritium commented 4 years ago

Hi, I am having troubles trying to open a magnet URL with this code:

const torrentStream = require('torrent-stream')

var magnetUrl = "weird magnet url"

try {
  ts = torrentStream(magnetUrl)
} catch (e) {
  console.log('it is not happening')
}

It returns

/Users/jose.galisteo/work/fuse-torrent/node_modules/parse-torrent-file/node_modules/bencode/lib/decode.js:50
  throw new Error(
  ^

Error: Invalid data: Missing delimiter ":" [0x3a]
    at Function.decode.find (/Users/jose.galisteo/work/fuse-torrent/node_modules/parse-torrent-file/node_modules/bencode/lib/decode.js:50:9)
    at Function.decode.bytes (/Users/jose.galisteo/work/fuse-torrent/node_modules/parse-torrent-file/node_modules/bencode/lib/decode.js:103:23)
    at Function.decode.next (/Users/jose.galisteo/work/fuse-torrent/node_modules/parse-torrent-file/node_modules/bencode/lib/decode.js:33:30)
    at Object.decode (/Users/jose.galisteo/work/fuse-torrent/node_modules/parse-torrent-file/node_modules/bencode/lib/decode.js:19:17)
    at decodeTorrentFile (/Users/jose.galisteo/work/fuse-torrent/node_modules/parse-torrent-file/index.js:16:23)
    at parseTorrent (/Users/jose.galisteo/work/fuse-torrent/node_modules/torrent-stream/node_modules/parse-torrent/index.js:22:12)
    at /Users/jose.galisteo/work/fuse-torrent/node_modules/torrent-stream/index.js:621:21
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

I have no problems opening other magnet URLs; the weird thing is that the problematic magnet URL works well on webtorrent.

I would like at least be able to catch the error. Any suggestion? I can share the magnet URL by PM

4c7x3n9 commented 4 years ago

Hi, i have the same problem did you solve that ?

ceritium commented 4 years ago

No, sorry.

4c7x3n9 commented 4 years ago

the problem i think is related to the file system i was running my application in alpine container then i switched to ubuntu and i no longer see this error again.

ceritium commented 4 years ago

Not sure, It's happening to me on macos.

josefson commented 4 years ago

I was also experiencing this same error on archlinux. It turned out after removing the /tmp/torrent-stream directory everything started working again