- 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.)
Fascinating.
I see you added the comment to the issue tracker. Google themselves had seemed to acknowledge it.
Link to the issue tracker: https://issuetracker.google.com/issues/149937257