Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upERR_SOCKET_BAD_PORT + can not catch error #1607
Comments
This comment has been minimized.
This comment has been minimized.
|
You are probably using the number The code below to catch the error is working for me: var Discovery = require("torrent-discovery")
try {
var discovery = new Discovery({
infoHash: '6a9759bffd5c0af65319979fb7832189f4f3c35d',
peerId: 'idyg789dg',
port: 2008,
announce: [
"udp://tracker.coppersurfer.tk:69691337"
]
});
} catch (err) {
console.log("ERROR: " + err);
} |
This comment has been minimized.
This comment has been minimized.
|
Hi @alxhotel here is reduced example of the code I used const WebTorrent = require('webtorrent')
const torrentClient = new WebTorrent()
...
const downloadTorrent = async (magnet) => {
try {
const torrentClient = new WebTorrent()
const torrent = await new Promise((resolve, reject) => {
torrentClient.add(magnet, torrentOptions, (torrent) => {
return resolve(torrent)
})
})
} catch (err) {
console.error('ERROR: ' + err)
}
}
...That construction doesn't allow you to catch exceptions, process just crashes. P.S. I've parsed magnet link with 'magnet-uri' module and found |
This comment has been minimized.
This comment has been minimized.
|
Ah got it. Thanks @flamewow. I think this is a bug in the |
This comment has been minimized.
This comment has been minimized.
|
This case should be handled in the tracker client indeed and just print a warning, ignoring the tracker. Willing to make a PR? |
What version of WebTorrent?
0.103.1
What operating system and Node.js version?
MacOS 10.14.3, nodejs 10.15.1
What browser and version? (if using WebTorrent in the browser)
What did you expect to happen?
download torrent (via magnet link) or handle the error gracefully.
What actually happened?
got error, couldn't catch it in any way. Process crashed.