Something doesn't make sense here. Aside from the fact that 'sleep' is generally a poor solution (how do you know how long to wait?), subshells on their own don't add any asynchrony: the only way that commands in a subshell could fail to exit before subsequent commands are run would be if the subshell in question were run in the background. That isn't the case here.
I think more investigation is needed. I'm confident that there's a better answer than inserting sleeps, but we won't know what until we know the true cause of this bug.
Something doesn't make sense here. Aside from the fact that 'sleep' is generally a poor solution (how do you know how long to wait?), subshells on their own don't add any asynchrony: the only way that commands in a subshell could fail to exit before subsequent commands are run would be if the subshell in question were run in the background. That isn't the case here.
I think more investigation is needed. I'm confident that there's a better answer than inserting sleeps, but we won't know what until we know the true cause of this bug.