- Run
useForLoop
independently, and observe it takes about 7 seconds to complete - Run
entrypoint
which calls useForLoop three times, asynchronously - Observe that the second run takes at least three times as long as the first run to complete
- Repeat the process above but in a browser, and observe the expected behaviour
Conclusion: Even though the documentation indicates that you can define async functions, and that you can make Promises, it ain't actually async.
Even more proof is in the fact in observing what happens when you run in the browser. It executes entrypoint()
immediately and "finishes" (although the calculations are still being made) and eventually outputs. But for the V8 engine, it indicates to the user that it is running and doesn't immediately return to the user.
- Why is
setTimeout
undefined butPromises
andAsyncFunction
work as expected (minus the actual async) - Will Google have another implementation where they do work?
Please see this gist to see the only way to do async on AppsScripts platform. (Note: It now requires you to create your own GCP project and link new project to that manually.)
Not sure why you're testing client-side.
In any case, how does useForLoop get called on the client-side?