I notice a strange behavior when trying to prematurely cancel from a Flow. Take a look at the following example.
This is a simple flow that emits integer values
I came up with this recently
it seems that it will only actually cancel if it reaches a suspending point and in your code that emits there is no such point
to solve this either add yield() between emissions or some other suspending function like delay(100)