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 up[CLOSED] TypeError: Cannot read property 'byteLength' of undefined #98
Comments
This comment has been minimized.
This comment has been minimized.
|
Thanks for the report. Will fix. |
This comment has been minimized.
This comment has been minimized.
|
I've really interested in this project and you've done a great job so far! I started a deep-dive of the bittorrent-* libs mainly to familiarize myself with everything but with this immediate bug in mind. To that end, I've found a few related issues.
should be changed to:
which is almost a noop except for validating that the metadata is valid bncoded. Then, the metadata that ut_metadata emits to listeners should be in the form { info : this.metadata }. The problem then comes in parsing the torrent's metadata where the following line fails because we just have the metadata info dictionary and not the whole .torrent file. I'm not nearly as familiar with the ins & outs of the protocols, but these areas seem to have contradicting assumptions. The other issue I ran into deals with the ordering of the onHandshake/onWire logic. Specifically, ut_metadata.onHandshake should be called before ut_metadata._checkDone, because _checkDone relies on having an infohash set, but in reality ut_metadata.onHandshake is never called. This appears to be because Wire._onHandshake (bittorrent-protocol) emits the handshake event after calling the extensions onHandshake, but in this case the handshake event that is emitted from Wire trickles up the stack to Swarm._onwire and Torrent._onWire, which is where the ut_metadata is initialized on the wire via
If I rearrange the emit to happen before calling the registered extension handshakes (allowing the torrent to register ut_metadata on the wire), this problem is resolved. That being said, the control flow for handshakes is confusing, so there may be a better solution to this problem. e.g. change:
to
|
This comment has been minimized.
This comment has been minimized.
|
@fisch0920 You're right on all counts. Thanks for all the PRs! They've all been merged |
This comment has been minimized.
This comment has been minimized.
|
|
Thursday Apr 24, 2014 at 17:24 GMT
Originally opened as https://github.com/feross/bittorrent-client/issues/2
Seems like quite an issue for me. Code:
Output:
You're getting a similar error on Travis, too. And you might have noticed the problem before, but I'm posting it just in case.