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 upDon't create wires until file verification is complete #889
Comments
This comment has been minimized.
This comment has been minimized.
|
So requests are being delayed to the ready event. If we are already requesting, doesn't that mean we have metadata? @feross |
This comment has been minimized.
This comment has been minimized.
|
We actually start the discovery process right away, even before the Maybe we should wait for the metadata? |
This comment has been minimized.
This comment has been minimized.
|
@roccomuso You can safely ignore this warning. It's not an issue. You can change |
This comment has been minimized.
This comment has been minimized.
|
@feross How come ready event hasn't fired if we already have the information about the pieces, as we are requesting them from wires (thus we have the metadata)? |
This comment has been minimized.
This comment has been minimized.
|
I think that we are doing verification of the existing file data on disk as the last step before the 'ready' event fires. |
This comment has been minimized.
This comment has been minimized.
|
Hi. I ran into this problem too; same error with the same stack trace. It seems the client is requesting pieces from peers before verification has completed. Which causes many listeners to be attached to the 'ready' event. Would it be better to not request any pieces until after verification? This makes more sense to me because we don't know what pieces we should request until after verification. To test this out, I added this line to _update in torrent.js Torrent.prototype._update = function () {
var self = this
if (self.destroyed) return
if (!self.ready) return // Add this line
......
}This fixed it, and all the tests still passed. @feross Do you think this is a good fix? Should I submit a PR? |
This comment has been minimized.
This comment has been minimized.
|
@xuset I think this is a good idea. But I think we should solve this by not creating any wires until after verification. Just returning from I'll leave this issue open to track this todo item. |
This comment has been minimized.
This comment has been minimized.
|
Any updates? |
This comment has been minimized.
This comment has been minimized.
|
I ran into the same problem - especially an issue on boxes with high connectivity and low cpu ressources. Based on @xuset fix I had another go:
@feross what do you think ? Edit: Managed to replicate with the fix, so |
This comment has been minimized.
This comment has been minimized.
|
#1350 fixes this I think (even though that wasn't the intention of the PR) Instead of waiting for the entire store to be verified, requests for a piece are cancelled unless that specific piece is verified. This means that while wires are created before the store is verified, wire.request() won't be called until that piece is verified in the store. This is essentially the same behavior as now, but the logic is applied for each piece individually instead of the whole store or nothing, and instead of making requests that wait until verification is complete, the request is cancelled and a new one is made once the piece is verified. Can anyone verify that the problem is solved with these changes? In the PR, I didn't touch the listener for the ready event in wire.request(), but I think it can be safely removed along with these changes right?
EDIT: I think the listener is still necessary for when torrent.critical() is used before file metadata is retrieved (return value from client.add() is used instead of the callback) because critical pieces don't wait for store verification in my PR. I think waiting for the ready event in client.critical() instead would be a good idea though, because that will only create as many listeners as calls to torrent.critical()
EDIT 2: Requests for critical pieces are now also cancelled before verification in the PR. It now removes the event listener as well. This is cleaner, and the benefit of downloading critical pieces before verification was probably insignificant, because those pieces are still prioritized for verification. |
This the warning i'm getting: