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

non-deterministic behavior: undefined property errors on console #792

Closed
miguelfreitas opened this issue May 8, 2016 · 6 comments
Closed

non-deterministic behavior: undefined property errors on console #792

miguelfreitas opened this issue May 8, 2016 · 6 comments
Labels

Comments

@miguelfreitas
Copy link
Contributor

@miguelfreitas miguelfreitas commented May 8, 2016

  • WebTorrent version: v0.91.4 - 2016-05-05
  • Browser name/version (if using WebTorrent in the browser): chrome 38

sometimes webtorrent works fine, but sometimes it does not (nothing changed - just page reloading)

  • torrent.numPeers is updated but torrent.downloadSpeed stays 0.
  • console shows the following errors (several times):

Uncaught TypeError: Cannot read property 'peerPieces' of undefined
Uncaught TypeError: Cannot read property 'isSeeder' of undefined

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 8, 2016

@miguelfreitas Thanks for the report. Can you share a complete stack trace? If you keep the Web Console open when you refresh the page, you might be able to get a more complete trace, which would aid in debugging. Thanks!

@feross feross added the question label May 8, 2016
@miguelfreitas

This comment has been minimized.

Copy link
Contributor Author

@miguelfreitas miguelfreitas commented May 8, 2016

guess what, it was very common behavior but now it seems difficult to reproduce...

i can't say i didn't changed anything because now i did (on my side, still the same webtorrent.min.js). but i'm pretty sure at one point i had it working/nonworking with just a browser reload.

i'll keep trying.

@miguelfreitas

This comment has been minimized.

Copy link
Contributor Author

@miguelfreitas miguelfreitas commented May 8, 2016

Got it:

Uncaught TypeError: Cannot read property 'peerPieces' of undefined VM644474:1
r.recalculate VM644474:1
t._onWire VM644474:1
r.emit VM644474:3
o._onWire VM644474:1
r.onHandshake VM644474:1
(anonymous function) VM644474:1
n VM644474:3
r.emit VM644474:3
o._onHandshake VM644474:2
(anonymous function) VM644474:2
o._write VM644474:2
d VM644474:6
f VM644474:6
s.write VM644474:6
s VM644474:5
r.emit VM644474:3
i VM644474:5
o.push VM644474:5
r._onChannelMessage VM644474:8
r._setupData.t._channel.onmessage
Uncaught TypeError: Cannot read property 'isSeeder' of undefined VM644474:1
(anonymous function) VM644474:1
o._rechoke VM644474:1
(anonymous function) VM644474:1
(anonymous function)
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 18, 2016

Aha! I think I've figured this one out!

If a peer disconnects, but the handshake they already sent hasn't been
processed by the wire yet (rare!) then onHandshake could be called
after the peer is destroyed.

At this point self.wire is null, so that will get pushed into the
self.swarm.wires array and cause this issue when wire.peerPieces is accessed.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 18, 2016

Released as v0.93.4.

@feross feross closed this in b7e10c5 May 18, 2016
@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 4, 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 4, 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.