Back

Function is "waiting" forever after I trigger its execution

  • 0
  • Functions
  • Cloud
Toli
21 Nov, 2023, 13:11

A cloud function won't run. I'm waiting for 7 minutes already, and it is still "waiting". Re-running it doesn't help...

TL;DR
The user is experiencing an issue where their function is "waiting" forever after triggering its execution. It is suggested to call the function asynchronously instead of synchronously because synchronous executions are limited to 30 seconds before they time out. The user also inquires about priority queues for paid users, but it is unclear if this feature is available. The user mentions that this issue has occurred twice, but it is not reproducible. No solution is provided in the thread.
Guille
21 Nov, 2023, 17:12

This could happen when you don't send any response, are you sure your code is responding something?

Drake
21 Nov, 2023, 20:23

Is this on cloud or self-hosted?

Toli
21 Nov, 2023, 20:30

Cloud.

Drake
21 Nov, 2023, 20:31

and it's still waiting?

Toli
21 Nov, 2023, 20:32

I couldn't reproduce it anymore though, must have been a temporary glitch. However it's the second time I encounter it.

Drake
21 Nov, 2023, 20:32

we did have a high load at this time so that may have been the reason

Toli
21 Nov, 2023, 20:32

No, I think at some point it did execute normally

Drake
21 Nov, 2023, 20:33

async executions get queued and then they're processed in FIFO order.

Toli
21 Nov, 2023, 20:34

I see... Will paid users get a priority queue or something? Wouldn't be nice if in production my app's api fails to respond at random times...

Drake
21 Nov, 2023, 20:38

API? synchronous executions are executed isntantly

Toli
21 Nov, 2023, 20:39

I mean, not the Appwrite API but functions-as-an-API scenario. Think e.g. an AI app that uses OpenAI to respond to the end user. The end user can't really call OpenAI directly since they need my secret key. Hence they will call my cloud function as a user-facing API.

Toli
21 Nov, 2023, 20:40

Not sure if that's the original intent of the cloud functions, but that's the best way I found to implement the above app in a serverless setting.

Drake
21 Nov, 2023, 20:43

if you have functions as an api, you'd be executing the function synchronously.

However, synchronous executions are limited to 30 seconds before they time out which OpenAI can take longer than that, so you'd have to execute that asynchronously.

Drake
21 Nov, 2023, 20:43

nontheless, I'm not sure about priority queues. I've reached out to the team about it

Toli
21 Nov, 2023, 20:44

nontheless, I'm not sure about priority queues. I've reached out to the team about it

Thanks for checking that for me!

However, synchronous executions are limited to 30 seconds before they time out which OpenAI can take longer than that, so you'd have to execute that asynchronously.

Still better than Vercel's limit of 10 seconds 🙂 but maybe there's a better way to implement the scenario I described? With everyone having those limits, it feels like I'm struggling against the cloud here.

Toli
21 Nov, 2023, 20:45

if you have functions as an api, you'd be executing the function synchronously. I didn't know there's a difference between calling a function via REST API and calling it from the dashboard, that's helpful!

Drake
21 Nov, 2023, 20:51

via REST API? Which exactly?

Toli
21 Nov, 2023, 20:54

I mean doing a fetch to the function's domain, as displayed under the "Domains" tab at the function settings on the Appwrite dashboard.

Drake
21 Nov, 2023, 21:10

Ah right. Ya that's considered a synchronous execution.

If you call the create execution API, there's an async param that you can set to true or false

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