How can I work with long running CloudCode tasks that return a response to the app?

I have a CloudCode task that is triggered from the app, but sometimes takes longer than a minute to run. How do I ensure that the request from the app doesn't time out?

With such CloudCode tasks, the request from the app times out after a minute, even though the CloudCode task itself keeps running on the server side until it completes (or hits the duration limit).

If you can't easily reduce the duration of the task, you can change to an asynchronous workflow, which would also avoid blocking the user for the entire time:

  1. Create a new object to initiate the call.
  2. Have a "ready" webhook on that model to call the CloudCode task.
  3. If you need to give feedback to the user, you can use something like setInterval() with an OnlineDB call to poll for updates.