Back

Is there a way to make an synchronous function run longer than 30 seconds?

  • 0
  • Self Hosted
  • Functions
memoonlite
14 Dec, 2023, 12:52

Hello everyone! 😊

One of my functions is experiencing the "Operation timed out after 30000 milliseconds with 0 bytes received with status code 0\nError Code: 0" error message.

From other topics regarding the same problem I understand that there is a 30 seconds time out value hard coded and that it's not controlled by the time out value that can be set on the settings page.

I was wondering: Is it possible to bypass this 30 seconds limit somehow? My function doesn’t always run for more than 30 seconds, but it’s frustrating that execution is cut off when it does (resulting in database inconsistencies).

TL;DR
The user is experiencing a 30-second timeout error when running a function. They are asking if there is a way to bypass this limit. Some suggestions are to switch to an asynchronous function and poll for updates or open a realtime socket, or to tweak the hardcoded timeout if self-hosted. The user plans to move to the cloud and asks if the same 30-second limit applies there. No solution is provided in the thread.
D5
14 Dec, 2023, 12:57

Is this Appwrite cloud?

memoonlite
14 Dec, 2023, 12:59

Self hosted for now, but I'll move to Cloud when I finished development. But the the same 30 seconds limit applies to Cloud, right?

D5
14 Dec, 2023, 13:03

From what I understand in self-hosting if you set the timeout value longer than 30s in the settings tab, it should run longer

memoonlite
14 Dec, 2023, 14:08

That's what I thought as well, but it seems like that setting only applies to asynchronous functions (if I understand it correctly). For synchronous functions execution ends if it runs longer than 30 seconds.

memoonlite
14 Dec, 2023, 14:12

By asynchronous I mean functions that are executed with the "xasync=true" parameter passed (which doesn't return a result).

memoonlite
14 Dec, 2023, 14:12

Unfortunately all my function are synchronous and thus can't run longer that 30 seconds it seems. πŸ’€

D5
14 Dec, 2023, 14:19

I double checked and that's true. Sync functions are capped to 30s

ideclon
14 Dec, 2023, 14:39

I would expect this is because a synchronous Function means keeping the HTTP request waiting until the Function ends. 30 seconds is a common default HTTP connection time limit.

Drake
14 Dec, 2023, 17:20
memoonlite
14 Dec, 2023, 21:01

Thanks! πŸ‘πŸ» I think it was introduced in a recent version, as all posts regarding this error message are from the past few months.

memoonlite
14 Dec, 2023, 21:04

Makes sense. πŸ‘πŸ» Thanks. It's not always desirable though. Cutting off a function can lead to database inconsistencies, when only a certain part of the function executes and the rest is cut off.

memoonlite
14 Dec, 2023, 21:21

Thanks for this. πŸ‘πŸ» I'm not a huge fan of making such change, as it might break something else. And also I'm going to move to Cloud later on. But it's good to know the possibility is there, so thanks. πŸ‘πŸ»

ideclon
14 Dec, 2023, 21:41

I would expect that making it longer than that would carry a risk of the connection being cut off by something else in the path. And it's generally going to be bad UX for the user to just be sitting around with no indication of what's happening. At that length, you might as well switch to an asynchronous Function and poll for updates, or even open a Realtime socket to listen for the completion

memoonlite
15 Dec, 2023, 06:28

Thanks for these new insights. πŸ‘πŸ»

That's right, it'd be bad if a function really takes 30 seconds to complete, and I definitely didn't design my function that way. Honestly I think these timeouts were caused by a bug some sort, because I never saw that error message again after a few executions. I'll move my self hosted environment to Cloud and try how it goes there.

Either way, thanks everyone who commented their input on this topic. πŸ‘πŸ»

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