In waitUntilAllDoneOrFailed() method in StoryManager Class, inside while loop we are iterating a HashMap (runningStories) in a for each loop.
Since we are using a HashMap, order is not guaranteed over time, and thus there's a chance to exit prematurely the while loop, if:
There is no in progress task, i.e. all tasks are either done or not started (or marked as that).
Last task is done.
This exists the while loop, without waiting for all task to finish.