79393889

Date: 2025-01-28 12:54:40
Score: 1
Natty:
Report link

Inline with @TheMaster comment, it is indeed parallel and asynchronous. It is the behavior of google.script.run. They are sent to the server and executed independently, without waiting for others to finish. You also need to keep in mind that the order depends on the execution time of each server-side function. Faster calls will complete earlier, regardless of the order they were initiated.

You can check this documentation Class google.script.run (Client-side API)

The Results in your example are expected to finish in this order:

Call 2 - 3s
Call 3 - 4s
Call 1 - 5s

This is because Call 2 has the shortest execution time, so it finishes first at 3s.

Server-side functions are queued in parallel, but they are handled by the Google Apps Script execution engine, which processes each other independently. The actual timing can vary depending on server load, quota limits, or other external factors.

If the order in which results are processed matters, you must manage this explicitly.

For instance:

You also need to consider that If too many google.script.run calls are made in a short time, they might hit quota limits or delays due to the Apps Script execution environment. Avoid making a very large number of simultaneous calls.

Other documentation I have read that might help you in organizing asynchronous And if you're running things in parallel using html.

Reasons:
  • Blacklisted phrase (1): this document
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @TheMaster
  • Low reputation (0.5):
Posted by: Alma_Matters