Suppose your code do things with texts in a doc that may, or may not, have smart reflow. Problem is that pages are updated asynchronously by default, so your script is unaware of what will actually change (Pages, TextFrames…) and then makes decisions on an wrong picture.