Conversation
👇 Click on the image for a new way to code review
Legend |
|
Ok there's another concurrency non-determinism. This time caused by a slower write while there is a write stream. It's quite confusing. But this is my theory. We have a write stream that writes 10 chunks of Now we also have an atomic call to a duplicated FD but that which starts at position 0. It writes 25 characters of The test currently expects the 25 characters to be written atomically. Therefore the test thinks the end result is either one of these: But the problem with this expectation is that, the former is true if the B write occurred first, and then A writes started. The latter can occur when A writes complete, then B write starts. But if B write starts in the middle of A writes. Then we would get a mixed output. This is because:
Hence is why we have: Now this could also change if the B writes occurs after the 2nd chunk. In that case we should use The reason why this is quite non-deterministic is because there are 2 levels of asynchronicity here. The ones involving But the end result is that the B writes can occur at any point in time between the atomic A writes. This is the same problem as the previous problem, but it wasn't as clear, because B writes starting from position 0, whereas A writes are in sequence. |
|
So the solution could be to strictly control the concurrency, but that doesn't allow our test to be robust. A robust test here should instead have a predicate that allows any of the possible permutations of the output. That being of all As, or any number of chunks of B based on the chunk size of A, up to 5 chunks (the length of B divided by the chunk size of A). |
…cryptedFS.createWriteStream`
|
This has been resolved with a more robust regex check. I suspect more of these bugs are lurking in the tests. |
|
Pipeline Succeeded on 599152359 for 92efef0 |

This is an automatic PR generated by the pipeline CI/CD. This will be automatically fast-forward merged if successful.