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

TypeError: Cannot read property 'length' of undefined #541

Closed
vinz243 opened this issue Dec 28, 2015 · 3 comments
Closed

TypeError: Cannot read property 'length' of undefined #541

vinz243 opened this issue Dec 28, 2015 · 3 comments

Comments

@vinz243
Copy link
Contributor

@vinz243 vinz243 commented Dec 28, 2015

I'm trying to use webtorrent in node. Here's my main class that serves as an interface between my code and webtorrent:

'use strict';

const EventEmitter = require('events').EventEmitter;
const WebTorrent = require('webtorrent');
let wtClient = new WebTorrent();

var normalize = (data) => {
  for(let key in data) {

    if(typeof data[key] === 'function' || key[0] === '_') {
      delete data[key];
    }
  }
};

class Client extends EventEmitter {
    constructor () {
      super();
      EventEmitter.call(this);

    }
    status () {

      return new Promise((resolve, reject) => {
        setTimeout(() => {
          return resolve('online');
        }, 250);
        setTimeout(() => {
          this.emit('client:status');
        }, 1250);
      });
    }
    addTorrent (opts) {
      return new Promise((resolve, reject) => {
        try {
          let torrent = wtClient.add(opts.source, (torrent) => {
            this.emit('torrent:' + torrent.infoHash + ':loaded', normalize(torrent));
            resolve(normalize(torrent));
          });

          torrent.on('download', (chunkSize) => {
            console.log(chunkSize);
            this.emit('torrent:' + torrent.infoHash + ':download', chunkSize);
          });
        } catch(err) {
          reject(err);
        }
      });
    }
  };

module.exports = Client;

And then to call it in browser:

var MAGNET_URI = 'magnet:?xt=urn:btih:09e37f73e51f403bb543517f0d0a2e1283d61eb0&dn=archlinux-2015.12.01-dual.iso&tr=udp://tracker.archlinux.org:6969&tr=http://tracker.archlinux.org:6969/announce';
socketClient.connect().then(() => {
    console.log('Connected to webtorrent');
    return socketClient.status();
}).then((res) => {
    console.log(res);
    return socketClient.addTorrent({source: MAGNET_URI});
}).then((data) => {
    console.log('Added torrent:', data);
}).catch((err) => {
    console.log(err);
});

And here is the output of DEBUG=webtorrent,bittorrent-protocol npm start

root@ubuntu-512mb-lon1-01:~/pTorrent# DEBUG=webtorrent,bittorrent-protocol npm start

> pTorrent@0.0.2 start /root/pTorrent
> node server.js --env=dev

  webtorrent new webtorrent (peerId 2d5757303036332d356230303535383263346539, nodeId ba46557fb5999d07269bb093813dc09b00be0ca9) +0ms
Listening at localhost:8080
Opening your system browser...
Client connected...
... (webpack part)
Client connected...
  webtorrent add +25s
  bittorrent-protocol [2e1cfd4c] new wire +306ms
  bittorrent-protocol [2e1cfd4c] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +2ms
  bittorrent-protocol [f472762a] new wire +5ms
  bittorrent-protocol [f472762a] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +2ms
  bittorrent-protocol [558f22df] new wire +0ms
  bittorrent-protocol [558f22df] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +1ms
  bittorrent-protocol [12a47d15] new wire +1ms
  bittorrent-protocol [12a47d15] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [f71c1c1d] new wire +0ms
  bittorrent-protocol [f71c1c1d] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [399c52b1] new wire +1ms
  bittorrent-protocol [399c52b1] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [c810e940] new wire +0ms
  bittorrent-protocol [c810e940] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [ba6edefd] new wire +1ms
  bittorrent-protocol [ba6edefd] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [558f22df] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d6c74304434302db73b405a8db27a0cad5acd35 exts={ dht: false, extended: true } +5ms
  bittorrent-protocol [558f22df] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [558f22df] setKeepAlive true +1ms
  bittorrent-protocol [558f22df] use extension.name=ut_metadata +1ms
  bittorrent-protocol [558f22df] use extension.name=ut_pex +0ms
  bittorrent-protocol [558f22df] extended ext=0 +2ms
  bittorrent-protocol [558f22df] extended ext=ut_metadata +1ms
  bittorrent-protocol [558f22df] extended ext=ut_metadata +1ms
  bittorrent-protocol [558f22df] got extended handshake +0ms
  bittorrent-protocol [558f22df] got bitfield +0ms
  bittorrent-protocol [12a47d15] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d4445313342302d596143694d3459637a4a6c4e exts={ dht: true, extended: true } +1ms
  bittorrent-protocol [12a47d15] port 45569 +0ms
  bittorrent-protocol [12a47d15] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [12a47d15] setKeepAlive true +1ms
  bittorrent-protocol [12a47d15] use extension.name=ut_metadata +0ms
  bittorrent-protocol [12a47d15] use extension.name=ut_pex +0ms
  bittorrent-protocol [12a47d15] extended ext=0 +1ms
  bittorrent-protocol [12a47d15] extended ext=ut_metadata +1ms
  bittorrent-protocol [12a47d15] extended ext=ut_metadata +0ms
  bittorrent-protocol [12a47d15] got extended handshake +0ms
  bittorrent-protocol [12a47d15] got bitfield +0ms
  bittorrent-protocol [f71c1c1d] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d6c74304434302d25326601715ec1e179a82d1f exts={ dht: false, extended: true } +2ms
  bittorrent-protocol [f71c1c1d] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [f71c1c1d] setKeepAlive true +0ms
  bittorrent-protocol [f71c1c1d] use extension.name=ut_metadata +0ms
  bittorrent-protocol [f71c1c1d] use extension.name=ut_pex +1ms
  bittorrent-protocol [f71c1c1d] extended ext=0 +0ms
  bittorrent-protocol [f71c1c1d] extended ext=ut_metadata +1ms
  bittorrent-protocol [f71c1c1d] extended ext=ut_metadata +3ms
  bittorrent-protocol [f71c1c1d] got extended handshake +0ms
  bittorrent-protocol [f71c1c1d] got bitfield +0ms
  bittorrent-protocol [33f1b6cd] new wire +3ms
  bittorrent-protocol [33f1b6cd] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [ba6edefd] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d6c74304434302dc24898d7137661f9d8498da0 exts={ dht: false, extended: true } +1ms
  bittorrent-protocol [ba6edefd] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [ba6edefd] setKeepAlive true +0ms
  bittorrent-protocol [ba6edefd] use extension.name=ut_metadata +0ms
  bittorrent-protocol [ba6edefd] use extension.name=ut_pex +1ms
  bittorrent-protocol [ba6edefd] extended ext=0 +0ms
  bittorrent-protocol [ba6edefd] extended ext=ut_metadata +0ms
  bittorrent-protocol [ba6edefd] extended ext=ut_metadata +5ms
  bittorrent-protocol [ba6edefd] got extended handshake +1ms
  bittorrent-protocol [ba6edefd] got bitfield +0ms
  bittorrent-protocol [399c52b1] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d4445313343302d2e4c3270766e7552596e5964 exts={ dht: true, extended: true } +0ms
  bittorrent-protocol [399c52b1] port 45569 +0ms
  bittorrent-protocol [399c52b1] setTimeout ms=30000 unref=true +1ms
  bittorrent-protocol [399c52b1] setKeepAlive true +0ms
  bittorrent-protocol [399c52b1] use extension.name=ut_metadata +0ms
  bittorrent-protocol [399c52b1] use extension.name=ut_pex +0ms
  bittorrent-protocol [399c52b1] extended ext=0 +1ms
  bittorrent-protocol [399c52b1] extended ext=ut_metadata +0ms
  bittorrent-protocol [399c52b1] extended ext=ut_metadata +1ms
  bittorrent-protocol [399c52b1] got extended handshake +0ms
  bittorrent-protocol [399c52b1] got bitfield +0ms
  bittorrent-protocol [399c52b1] got port 43097 +0ms
  bittorrent-protocol [c810e940] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d6c74304432302dc6fe0b64d5b645a0828760ef exts={ dht: false, extended: true } +2ms
  bittorrent-protocol [c810e940] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [c810e940] setKeepAlive true +0ms
  bittorrent-protocol [c810e940] use extension.name=ut_metadata +0ms
  bittorrent-protocol [c810e940] use extension.name=ut_pex +1ms
  bittorrent-protocol [c810e940] extended ext=0 +0ms
  bittorrent-protocol [c810e940] extended ext=ut_metadata +1ms
  bittorrent-protocol [c810e940] extended ext=ut_metadata +0ms
  bittorrent-protocol [c810e940] got extended handshake +0ms
  bittorrent-protocol [c810e940] got bitfield +0ms
  bittorrent-protocol [31162174] new wire +0ms
  bittorrent-protocol [31162174] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +1ms
  bittorrent-protocol [c5934307] new wire +0ms
  bittorrent-protocol [c5934307] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [41c89142] new wire +1ms
  bittorrent-protocol [41c89142] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [d2947b06] new wire +0ms
  bittorrent-protocol [d2947b06] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [df0b5ba3] new wire +1ms
  bittorrent-protocol [df0b5ba3] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [004bdcfd] new wire +0ms
  bittorrent-protocol [004bdcfd] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +1ms
  bittorrent-protocol [bbd4d294] new wire +0ms
  bittorrent-protocol [bbd4d294] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [2b56dcc7] new wire +0ms
  bittorrent-protocol [2b56dcc7] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +1ms
  bittorrent-protocol [1ac87179] new wire +0ms
  bittorrent-protocol [1ac87179] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [b9795856] new wire +2ms
  bittorrent-protocol [b9795856] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [33f1b6cd] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5554333435302d9ca1fddd7c14e570571f8a03 exts={ dht: true, extended: true } +2ms
  bittorrent-protocol [33f1b6cd] port 45569 +0ms
  bittorrent-protocol [33f1b6cd] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [33f1b6cd] setKeepAlive true +0ms
  bittorrent-protocol [33f1b6cd] use extension.name=ut_metadata +1ms
  bittorrent-protocol [33f1b6cd] use extension.name=ut_pex +0ms
  bittorrent-protocol [33f1b6cd] extended ext=0 +0ms
  bittorrent-protocol [2531f10a] new wire +1ms
  bittorrent-protocol [2531f10a] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [19d21c6d] new wire +0ms
  bittorrent-protocol [19d21c6d] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [c1bdd8be] new wire +13ms
  bittorrent-protocol [c1bdd8be] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [558f22df] got extended message ext=ut_metadata +3ms
  bittorrent-protocol [12a47d15] got extended message ext=ut_metadata +3ms
  bittorrent-protocol [558f22df] bitfield +14ms
  bittorrent-protocol [558f22df] interested +1ms
  bittorrent-protocol [12a47d15] bitfield +0ms
  bittorrent-protocol [12a47d15] interested +0ms
  bittorrent-protocol [f71c1c1d] bitfield +1ms
  bittorrent-protocol [f71c1c1d] interested +0ms
  bittorrent-protocol [ba6edefd] bitfield +1ms
  bittorrent-protocol [ba6edefd] interested +0ms
  bittorrent-protocol [399c52b1] bitfield +1ms
  bittorrent-protocol [399c52b1] interested +0ms
  bittorrent-protocol [c810e940] bitfield +0ms
  bittorrent-protocol [c810e940] interested +0ms
  bittorrent-protocol [33f1b6cd] bitfield +1ms
  bittorrent-protocol [33f1b6cd] interested +0ms
  bittorrent-protocol [12a47d15] got extended message ext=ut_metadata +16ms
  bittorrent-protocol [41c89142] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d4445313343302d6c67466d4658306f4e466676 exts={ dht: true, extended: true } +2ms
  bittorrent-protocol [41c89142] port 45569 +0ms
  bittorrent-protocol [41c89142] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [41c89142] setKeepAlive true +1ms
  bittorrent-protocol [41c89142] use extension.name=ut_metadata +0ms
  bittorrent-protocol [41c89142] use extension.name=ut_pex +0ms
  bittorrent-protocol [41c89142] bitfield +1ms
  bittorrent-protocol [41c89142] interested +2ms
  bittorrent-protocol [41c89142] extended ext=0 +3ms
  bittorrent-protocol [41c89142] got extended handshake +0ms
  bittorrent-protocol [41c89142] got bitfield +0ms
  bittorrent-protocol [41c89142] got port 58767 +2ms
  bittorrent-protocol [33f1b6cd] got extended handshake +1ms
  bittorrent-protocol [33f1b6cd] got bitfield +0ms
  bittorrent-protocol [33f1b6cd] got have 1077 +1ms
  bittorrent-protocol [33f1b6cd] got have 1276 +1ms
  bittorrent-protocol [33f1b6cd] got have 1317 +0ms
  bittorrent-protocol [33f1b6cd] got have 1233 +0ms
  bittorrent-protocol [33f1b6cd] got have 945 +0ms
  bittorrent-protocol [33f1b6cd] got have 724 +0ms
  bittorrent-protocol [33f1b6cd] got have 622 +0ms
  bittorrent-protocol [33f1b6cd] got have 324 +0ms
  bittorrent-protocol [33f1b6cd] got have 927 +1ms
  bittorrent-protocol [33f1b6cd] got have 563 +0ms
  bittorrent-protocol [33f1b6cd] got have 248 +0ms
  bittorrent-protocol [33f1b6cd] got have 1215 +0ms
  bittorrent-protocol [33f1b6cd] got have 1268 +0ms
  bittorrent-protocol [33f1b6cd] got have 1266 +1ms
  bittorrent-protocol [33f1b6cd] got have 449 +0ms
  bittorrent-protocol [33f1b6cd] got have 409 +0ms
  bittorrent-protocol [33f1b6cd] got have 614 +0ms
  bittorrent-protocol [33f1b6cd] got have 1259 +0ms
  bittorrent-protocol [33f1b6cd] got have 550 +1ms
  bittorrent-protocol [33f1b6cd] got have 210 +0ms
  bittorrent-protocol [33f1b6cd] got have 953 +0ms
  bittorrent-protocol [33f1b6cd] got have 1155 +0ms
  bittorrent-protocol [33f1b6cd] got have 806 +0ms
  bittorrent-protocol [33f1b6cd] got have 1131 +0ms
  bittorrent-protocol [c5934307] destroy +1ms
  bittorrent-protocol [c5934307] end +0ms
  bittorrent-protocol [c5934307] got uninterested +0ms
  bittorrent-protocol [c5934307] got choke +1ms
  bittorrent-protocol [ba6edefd] got extended message ext=ut_metadata +3ms
  bittorrent-protocol [f71c1c1d] got extended message ext=ut_metadata +1ms
  bittorrent-protocol [d2947b06] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d7142333331302d4a375242214f59766f2d464f exts={ dht: true, extended: true } +1ms
  bittorrent-protocol [d2947b06] port 45569 +0ms
  bittorrent-protocol [d2947b06] setTimeout ms=30000 unref=true +1ms
  bittorrent-protocol [d2947b06] setKeepAlive true +0ms
  bittorrent-protocol [d2947b06] use extension.name=ut_metadata +0ms
  bittorrent-protocol [d2947b06] use extension.name=ut_pex +0ms
  bittorrent-protocol [d2947b06] bitfield +1ms
  bittorrent-protocol [d2947b06] interested +0ms
  bittorrent-protocol [d2947b06] extended ext=0 +1ms
  bittorrent-protocol [d2947b06] got extended handshake +1ms
  bittorrent-protocol [d2947b06] got bitfield +0ms
  bittorrent-protocol [d2947b06] got have 21 +1ms
  bittorrent-protocol [d2947b06] got have 33 +0ms
  bittorrent-protocol [d2947b06] got have 66 +0ms
  bittorrent-protocol [d2947b06] got have 98 +1ms
  bittorrent-protocol [d2947b06] got have 134 +0ms
  bittorrent-protocol [d2947b06] got have 171 +0ms
  bittorrent-protocol [d2947b06] got have 201 +0ms
  bittorrent-protocol [d2947b06] got have 221 +0ms
  bittorrent-protocol [d2947b06] got have 228 +0ms
  bittorrent-protocol [d2947b06] got have 230 +0ms
  bittorrent-protocol [d2947b06] got have 231 +0ms
  bittorrent-protocol [d2947b06] got have 236 +0ms
  bittorrent-protocol [d2947b06] got have 244 +1ms
  bittorrent-protocol [d2947b06] got have 307 +0ms
  bittorrent-protocol [d2947b06] got have 364 +0ms
  bittorrent-protocol [d2947b06] got have 389 +0ms
  bittorrent-protocol [d2947b06] got have 401 +0ms
  bittorrent-protocol [d2947b06] got have 411 +0ms
  bittorrent-protocol [d2947b06] got have 412 +1ms
  bittorrent-protocol [d2947b06] got have 439 +0ms
  bittorrent-protocol [d2947b06] got have 476 +0ms
  bittorrent-protocol [d2947b06] got have 480 +0ms
  bittorrent-protocol [d2947b06] got have 493 +0ms
  bittorrent-protocol [d2947b06] got have 531 +1ms
  bittorrent-protocol [d2947b06] got have 546 +1ms
  bittorrent-protocol [d2947b06] got have 584 +0ms
  bittorrent-protocol [d2947b06] got have 605 +0ms
  bittorrent-protocol [d2947b06] got have 680 +0ms
  bittorrent-protocol [d2947b06] got have 705 +1ms
  bittorrent-protocol [d2947b06] got have 796 +0ms
  bittorrent-protocol [d2947b06] got have 819 +0ms
  bittorrent-protocol [d2947b06] got have 860 +0ms
  bittorrent-protocol [d2947b06] got have 882 +0ms
  bittorrent-protocol [d2947b06] got have 889 +0ms
  bittorrent-protocol [d2947b06] got have 899 +0ms
  bittorrent-protocol [d2947b06] got have 902 +0ms
  bittorrent-protocol [d2947b06] got have 1086 +1ms
  bittorrent-protocol [d2947b06] got have 1124 +0ms
  bittorrent-protocol [d2947b06] got have 1139 +0ms
  bittorrent-protocol [d2947b06] got have 1150 +0ms
  bittorrent-protocol [d2947b06] got have 1160 +0ms
  bittorrent-protocol [d2947b06] got have 1166 +0ms
  bittorrent-protocol [d2947b06] got have 1170 +0ms
  bittorrent-protocol [d2947b06] got have 1171 +0ms
  bittorrent-protocol [d2947b06] got have 1190 +0ms
  bittorrent-protocol [d2947b06] got have 1209 +0ms
  bittorrent-protocol [d2947b06] got have 1215 +1ms
  bittorrent-protocol [d2947b06] got have 1253 +0ms
  bittorrent-protocol [d2947b06] got have 1255 +0ms
  bittorrent-protocol [d2947b06] got have 1312 +0ms
  bittorrent-protocol [d2947b06] got port 8999 +0ms
  bittorrent-protocol [6fa0183f] new wire +0ms
  bittorrent-protocol [6fa0183f] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +1ms
  bittorrent-protocol [7405a869] new wire +0ms
  bittorrent-protocol [7405a869] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [399c52b1] got extended message ext=ut_metadata +2ms
  bittorrent-protocol [399c52b1] got extended message ext=ut_metadata +0ms
  bittorrent-protocol [399c52b1] got unchoke +0ms
  bittorrent-protocol [31162174] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d4445313343302d7162285471362e4a7a77635f exts={ dht: true, extended: true } +1ms
  bittorrent-protocol [31162174] port 45569 +0ms
  bittorrent-protocol [31162174] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [31162174] setKeepAlive true +0ms
  bittorrent-protocol [31162174] use extension.name=ut_metadata +1ms
  bittorrent-protocol [31162174] use extension.name=ut_pex +0ms
  bittorrent-protocol [31162174] bitfield +0ms
  bittorrent-protocol [31162174] interested +1ms
  bittorrent-protocol [31162174] extended ext=0 +1ms
  bittorrent-protocol [b9795856] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5554333435302d9ca1976b6bd37727f691ab13 exts={ dht: true, extended: true } +4ms
  bittorrent-protocol [b9795856] port 45569 +0ms
  bittorrent-protocol [b9795856] setTimeout ms=30000 unref=true +1ms
  bittorrent-protocol [b9795856] setKeepAlive true +0ms
  bittorrent-protocol [b9795856] use extension.name=ut_metadata +0ms
  bittorrent-protocol [b9795856] use extension.name=ut_pex +0ms
  bittorrent-protocol [b9795856] bitfield +1ms
  bittorrent-protocol [b9795856] interested +1ms
  bittorrent-protocol [b9795856] extended ext=0 +1ms
  bittorrent-protocol [850370cf] new wire +1ms
  bittorrent-protocol [850370cf] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [d4ad319e] new wire +0ms
  bittorrent-protocol [d4ad319e] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +0ms
  bittorrent-protocol [c810e940] destroy +1ms
  bittorrent-protocol [c810e940] end +1ms
  bittorrent-protocol [c810e940] got uninterested +0ms
  bittorrent-protocol [c810e940] got choke +0ms
  bittorrent-protocol [12a47d15] got unchoke +0ms
  bittorrent-protocol [8ef39423] new wire +0ms
  bittorrent-protocol [8ef39423] handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5757303036332d356230303535383263346539 exts={ dht: true } +1ms
  bittorrent-protocol [c1bdd8be] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5554333435302d9ca17401d1fe6fd68d234f4a exts={ dht: true, extended: true } +0ms
  bittorrent-protocol [c1bdd8be] port 45569 +0ms
  bittorrent-protocol [c1bdd8be] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [c1bdd8be] setKeepAlive true +0ms
  bittorrent-protocol [c1bdd8be] use extension.name=ut_metadata +1ms
  bittorrent-protocol [c1bdd8be] use extension.name=ut_pex +1ms
  bittorrent-protocol [c1bdd8be] bitfield +0ms
  bittorrent-protocol [c1bdd8be] interested +0ms
  bittorrent-protocol [c1bdd8be] extended ext=0 +2ms
  bittorrent-protocol [2b56dcc7] got handshake i=09e37f73e51f403bb543517f0d0a2e1283d61eb0 p=2d5452323834302d336331746f796c6a72716239 exts={ dht: true, extended: true } +3ms
  bittorrent-protocol [2b56dcc7] port 45569 +0ms
  bittorrent-protocol [2b56dcc7] setTimeout ms=30000 unref=true +0ms
  bittorrent-protocol [2b56dcc7] setKeepAlive true +0ms
  bittorrent-protocol [2b56dcc7] use extension.name=ut_metadata +0ms
  bittorrent-protocol [2b56dcc7] use extension.name=ut_pex +1ms
  bittorrent-protocol [2b56dcc7] bitfield +0ms
  bittorrent-protocol [2b56dcc7] interested +0ms
  bittorrent-protocol [2b56dcc7] extended ext=0 +21ms
  bittorrent-protocol [b9795856] got extended handshake +620ms
  bittorrent-protocol [b9795856] got bitfield +0ms
  bittorrent-protocol [b9795856] got have 716 +3ms
  bittorrent-protocol [b9795856] got have 911 +0ms
  bittorrent-protocol [b9795856] got have 168 +0ms
  bittorrent-protocol [b9795856] got have 558 +1ms
  bittorrent-protocol [b9795856] got have 436 +0ms
  bittorrent-protocol [b9795856] got have 439 +0ms
  bittorrent-protocol [b9795856] got have 354 +0ms
  bittorrent-protocol [b9795856] got have 371 +0ms
  bittorrent-protocol [b9795856] got have 483 +0ms
  bittorrent-protocol [b9795856] got have 514 +0ms
  bittorrent-protocol [b9795856] got have 647 +1ms
  bittorrent-protocol [b9795856] got have 1146 +0ms
  bittorrent-protocol [b9795856] got have 608 +0ms
  bittorrent-protocol [b9795856] got have 18 +1ms
  bittorrent-protocol [b9795856] got have 94 +0ms
  bittorrent-protocol [b9795856] got have 85 +0ms
  bittorrent-protocol [b9795856] got have 1031 +0ms
  bittorrent-protocol [b9795856] got have 951 +0ms
  bittorrent-protocol [b9795856] got have 472 +0ms
  bittorrent-protocol [b9795856] got have 121 +0ms
  bittorrent-protocol [b9795856] got have 1144 +0ms
  bittorrent-protocol [b9795856] got have 162 +1ms
  bittorrent-protocol [b9795856] got have 361 +0ms
  bittorrent-protocol [b9795856] got have 670 +0ms
  bittorrent-protocol [399c52b1] got extended message ext=ut_pex +1ms
  bittorrent-protocol [399c52b1] request index=1325 offset=0 length=16384 +30ms
  bittorrent-protocol [12a47d15] request index=1325 offset=16384 length=16384 +1ms
/root/pTorrent/node_modules/webtorrent/lib/torrent.js:722
  for (var i = 0; i < self._selections.length; i++) {
                                      ^

TypeError: Cannot read property 'length' of undefined
    at Torrent._gcSelections (/root/pTorrent/node_modules/webtorrent/lib/torrent.js:722:39)
    at Torrent._checkDone (/root/pTorrent/node_modules/webtorrent/lib/torrent.js:1163:8)
    at Torrent._onStore (/root/pTorrent/node_modules/webtorrent/lib/torrent.js:410:8)
    at /root/pTorrent/node_modules/webtorrent/lib/torrent.js:387:10
    at end (/root/pTorrent/node_modules/run-parallel/index.js:16:15)
    at done (/root/pTorrent/node_modules/run-parallel/index.js:20:10)
    at each (/root/pTorrent/node_modules/run-parallel/index.js:26:7)
    at /root/pTorrent/node_modules/webtorrent/lib/torrent.js:369:25
    at /root/pTorrent/node_modules/fs-chunk-store/index.js:195:23
    at end (/root/pTorrent/node_modules/run-parallel/index.js:16:15)

npm ERR! Linux 4.2.0-16-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.4
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! pTorrent@0.0.2 start: `node server.js --env=dev`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the pTorrent@0.0.2 start script 'node server.js --env=dev'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pTorrent package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node server.js --env=dev
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs pTorrent
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls pTorrent
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/pTorrent/npm-debug.log
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 28, 2015

This issue is caused by your normalize function. You're calling normalize(torrent) which removes everything that starts with _ which is deleting a bunch of internal properties of the torrent.

You shouldn't delete properties from the torrent object.

@feross feross closed this Dec 28, 2015
@vinz243

This comment has been minimized.

Copy link
Contributor Author

@vinz243 vinz243 commented Dec 28, 2015

Ah thanks. Will try to copy it instead

@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 5, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 5, 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
2 participants
You can’t perform that action at this time.