When receiving a response, what was happening
1. Read bufferSize and it gets assigned to leftdata
2. Read another bufferSize
3. 2 buffers get appended, but leftdata still points to first buffer
4. Process data buffer which contains only complete responses
5. Back to ReadLoop, but leftdata still points to first incomplete buffer
causing corrupt data to be processed
Solution is to make leftdata nil once we have merged it with the second buffer
1. It's easier to test with (it installs in the regular path), we need to start and stop it for network error tests
2. Can't hurt to test with both implementations!
Dodging the race condition with a sleep was fine, but we slept
for a whole second which was longer than this test takes to run!
I've scaled the sleep down to 250 miliseconds and increased the tries.
Even this is probably excessively long but now the test is fast agin.
Dodging the race condition with a sleep was fine, but we slept
for a whole second which was longer than this test takes to run!
I've scaled the sleep down to 250 miliseconds and increased the tries.
Even this is probably excessively long but now the test is fast agin.
* FIX: committed test froze
* FIX: committed test had a race condition!
* Added properly handled panic test
* Timeouts so that these tests should fail now if something goes wrong instead of failing.
worker.Immediately has value 2 which means the job will timeout after 2 seconds (maybe not very intuitive?). To have no timeout one has to pass the value 0 which is also constant worker.Unlimited (more intuitive)