JavaScript calls occasionally fail

It seems that sometimes JavaScript calls `didCompile()` before the latches are created, and the whole call times out on the Java side.