[streams] cancel.js test can be flaky (#413)

ReadableStream cancellation: integration test on an infinite stream derived from a random push source can be very flaky.

1. So the test begins with the creation of the RS and readableStreamToArray begins to pump.
2. After 15ms + day promise vending, reader.cancel is called
3. As a result of reader.cancel, the pending read is vended with done, which returns the chunks and creates the cascade of vending the read promises. I don't know how much async this is.
4. Then the source cancel is called. This creates a promise that sets the timeout to set cancellationFinished to true and vend the promise. Promise is returned.

The issue is that between the cascade of reads of point 3 in some cases I see the cancel promise timeout sneaking in and setting cancellationFinished to true so the assert_false inside the readableStreamToArray.

I know that promise vending should happen within the microtask loop, unlike timeouts, so I am not sure about this, but there's still a cascade of 6 reads to be solved (I manage to get 5 reads completed before the cancel plus the pending one) while we get the source cancel running and setting the timeout, that in significant amount of cases gets executed.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/413

Received on Thursday, 10 December 2015 18:36:25 UTC