Is there a way to make an synchronous function run longer than 30 seconds?
- 0
- Self Hosted
- Functions

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).

Is this Appwrite cloud?

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?

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

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.

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

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

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

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.

I think this is the hardcoded timeout: https://github.com/appwrite/appwrite/blob/5a715ff68cba4171bf3473eabc83b84a4ae5876c/app/controllers/api/functions.php#L1728C35-L1728C35
If you're self-hosting, you can try tweaking this

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

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.

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. ππ»

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

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. ππ»
Recommended threads
- Tables freeze in console 1.7.4
In version 1.7 of appwrite, tables start to freeze in console very much if there are a lot of elements (more than 96). The information takes a very long time to...
- "Memberships privacy" setting in 1.7.4
Hi everyone, I'm experiencing an issue with a clean self-hosted installation of Appwrite version 1.7.4. I previously used version 1.6.1, and if I remember corre...
- Storage getFilePreview for GIF file retu...
Used to work in 1.6.x but with 1.7.4 upgrade it seems to be broken.
