Closed jnordberg closed 8 years ago
I'm :+1:. Not sure this can be easily tested, if you have some idea just add one :).
Thinking a bit more about this, I fear we might need to put in a linear or exponential timeout in there, rather than a fixed 10ms (with a cap of 2-5s). If a user is on a slow connection, we'll be polling aggressively eating a lot of CPU power. When a user is on a slow connection, he is probably on battery, so better be nice. 10ms is too slow for a full round-trip anyway on the net.
Good point. I also noticed another thing now when using this: chrome throttles setTimeout's to max once a second when in a background tab, making background uploads super slow.
We could take the time and byte delta between two writes and try to figure out what the buffer size and delay should be... But maybe the best/simplest solution would be to just allow the socket buffer to grow to 10mb and set a fixed timeout of 1s? That would not allow for accurate speed measures for small files but at least it addresses the problem of cpu usage and background uploads.
I'm :+1: on that solution. However we should make that delay configurable. A magic number is fine, but let's give users a choice.
Made both parameters configurable and came up with some defaults after some testing with my crappy internet connection. Can't test locally since the buffer drains way faster than i can fill it.
500kb buffer with a 1000 ms interval seems to be a good compromise
I'm :+1: on this. Any other opinion: @mafintosh @maxogden?
just reviewed it, seems good to me. @mafintosh can you see any stream edge cases with this approach?
@maxogden no :+1: from me.
LGTM Il giorno ven 11 dic 2015 alle 00:28 Mathias Buus notifications@github.com ha scritto:
@maxogden https://github.com/maxogden no [image: :+1:] from me.
— Reply to this email directly or view it on GitHub https://github.com/maxogden/websocket-stream/pull/78#issuecomment-163785433 .
Added some documentation
@jnordberg awesomeness! I just published it as 2.3.0. I also added you as a collaborator (open open source style)
Cool! I'll make sure to follow the open open source spirit :) Happy holidays!
As discussed in #1