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
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Can't login or deploy functions in Appwr...
Hello, since i updatet to the appwrite cli 6.1.0 i can't login or deploy functions with the cli. When i call the command: "appwrite get account --verbose" i ge...
- Create admin user?
I'm not really sure how this is supposed to work, I installed Appwrite through docker-compose and set it up. When I launched the app and went into it, I created...