Back

Executing multiple server functions in parallel

  • 0
  • Web
  • Cloud
кеni
11 Jun, 2024, 14:32

I'm having trouble understanding how to use the async: true flag in the createExecution function. Do I need to create some sort of queue system? I can't find any examples of how to do this for Cloud + Web (Node.js)

When I try to run the following function multiple times without async: true It's only running the first one. If I add async: true I get a server error: Error: Function execution failed with status 0:

TypeScript
  try {
    const execution = await functions.createExecution(
      "6667045d000c65a2ddcb",
      id,
      true
    )

    if (
      execution.responseStatusCode >= 200 &&
      execution.responseStatusCode < 300
    ) {
      return JSON.parse(execution.responseBody)
    } else {
      throw new Error(
        `Function execution failed with status ${execution.responseStatusCode}: ${execution.responseBody}`
      )
    }
  } catch (error) {
    console.error("Error fetching payment from server: ", error)
    throw error
  }
}
TL;DR
Developers are struggling with executing multiple server functions in parallel due to issues with the `async: true` flag and empty `responseBody`. Possible need to rethink the approach and consider implementing a queue system. There is a server error `Error: Function execution failed with status 0:` when trying to execute the function multiple times with `async: true`.
кеni
11 Jun, 2024, 14:48

After playing around with some polling, I'm now getting an empty responseBody which might be tied to this issue: https://github.com/appwrite/appwrite/issues/6256

I guess I need to completely rethink they way I'm doing this

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more