Use a fixed interval for emitting progress events #68
Chaphasilor
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
|
Hello @Chaphasilor , sorry the very big late reply, yeap interesting although i don't like very much the idea of adding a setInterval, i would prefer to keep how it is now, the problem is that sometimes people like to get the information without any throttling, of course these could be fixed by just to have a setInterval(, 0), o very low value, but i am not very happy about it, i will think about it, but what is definitely needed is to have some sort of timeout if not new data is gotten in a period of time, i will take this into account when i do a new release in the future and disccus in here |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey @hgouveia,
I'm currently dealing with a very stubborn server that like to sometimes just stop responding, i.e. stop sending data, without terminating the connection.
When this happens, ndh won't emit any progress events anymore, because they are only emitted when a chunk is received via the tcp socket. Check this line here:
node-downloader-helper/src/index.js
Line 439 in ac8387f
The problem with this is two-fold:
downloadingindefinitely, no retries, no errors, nothing=> The download appears to be "frozen".
If we instead used something like
setInterval()to regularly emit the stats event, we could avoid this problem.Firstly, if no new chunk was received since the last interval, we can set the download speed to 0 b/s, or at least decrease it slowly.
And secondly, if no chunks are received for multiple seconds or even a minute, we could emit an
errorand try to restart the download using the resume feature (if resume is supported, otherwise completely restart it).This would simply consume one of the available retries, but should allow ndh to recover from such server errors on its own.
What do you think? :)
Beta Was this translation helpful? Give feedback.
All reactions