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

Cannot read property 'numPiecesPresent' of undefined #695

Closed
feross opened this issue Jun 30, 2016 · 3 comments
Closed

Cannot read property 'numPiecesPresent' of undefined #695

feross opened this issue Jun 30, 2016 · 3 comments

Comments

@feross
Copy link
Member

feross commented Jun 30, 2016

What version of WebTorrent Desktop? (See the 'About WebTorrent' menu)

0.8.1

What operating system and version?

OS X latest

What did you do?

Add a torrent

What did you expect to happen?

It starts.

What actually happened?

rendering error: Cannot read property 'numPiecesPresent' of undefined
TypeError: Cannot read property 'numPiecesPresent' of undefined
at renderFileRow (/Applications/WebTorrent.app/Contents/Resources/app.asar/renderer/views/home.js:227:24)
at torrentSummary.files.map.sort.map (/Applications/WebTorrent.app/Contents/Resources/app.asar/renderer/views/home.js:200:26)
at Array.map (native)
at renderTorrentDetails (/Applications/WebTorrent.app/Contents/Resources/app.asar/renderer/views/home.js:200:10)
at renderTorrent (/Applications/WebTorrent.app/Contents/Resources/app.asar/renderer/views/home.js:51:24)
at TorrentList.state.saved.torrents.map (/Applications/WebTorrent.app/Contents/Resources/app.asar/renderer/views/home.js:12:25)
at Array.map (native)
at Object.TorrentList as home
at getView (/Applications/WebTorrent.app/Contents/Resources/app.asar/renderer/views/app.js:81:20)
at App (/Applications/WebTorrent.app/Contents/Resources/app.asar/renderer/views/app.js:44:30)
main.js:470 webtorrent: sent wt-save-torrent-file
main.js:470 webtorrent: sent wt-generate-torrent-poster
main.js:470 webtorrent: got wt-progress
/Applications/WebTorrent.app/Contents/Resources/app.asar/node_modules/raf/index.js:74 Uncaught TypeError: Cannot read property 'ownerDocument' of null

@bnjmnt4n
Copy link
Member

I've gotten this error before (since a few versions back), but I'm not too sure why. If I read the code correctly, the code that accesses numPiecesPresent shouldn't be run if the torrent isn't ready yet.

@mathiasvr
Copy link
Contributor

This seems to happen if the torrent is expanded too fast, i.e. renderFileRow gets called before the wt-progress event. This especially becomes a problem when the torrent is expanded initially as it's added. I don't know why this would be the case, but when i tested it, if I removed a torrent when it was expanded and added it again it would still be expanded and often cause this crash.

A simple fix might be to null-check torrentSummary.progress.files[index] at this line, which seems alright since we are already checking the progress and files properties. However a more general way of determining the ready state of a torrent seems ideal.

@feross
Copy link
Member Author

feross commented Aug 4, 2016

Fixed the immediate issue using @mathiasvr's suggestion in PR #757.

@feross feross added this to the v0.10 milestone Aug 5, 2016
@dcposch dcposch removed their assignment Aug 8, 2016
@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants