I am facing a weird situation here. If for some reason I don't handle an exception thrown by my PHP function, the executor container will move to the exited docker state and will not process any other request. If I manually restart the container it will start processing requests again.
Shouldn't it have the always restarting policy?
One thing I noticed is that after several minutes it will create another container and then the requests will start to get processed again.
What version of Appwrite?
1.4.13
sooo the container shouldn't exit, even if your function throws an exception...can you try to check the runtime container logs?
here it is:
Preparing for start ...
Starting ...
Warning: foreach() argument must be of type array|object, null given in /usr/local/server/src/server.php on line 86
[2024-01-05 19:58:52 *9.0] ERROR php_swoole_server_rshutdown() (ERRNO 503): Fatal error: Uncaught TypeError: ValidateBody::__invoke(): Argument #1 ($body) must be of type array, string given, called in /usr/local/server/src/function/src/index.php on line 11 and defined in /usr/local/server/src/function/src/Actions/ValidateBody.php:4
Stack trace:
#0 /usr/local/server/src/function/src/index.php(11): ValidateBody->__invoke('')
#1 /usr/local/server/src/server.php(190): {closure}(Object(SSAWeb\AppwriteTestUtils\Context))
#2 /usr/local/server/src/server.php(199): {closure}()
#3 @swoole/library/core/Coroutine/functions.php(43): {closure}()
#4 [internal function]: Swoole\Coroutine\{closure}()
}
thrown in /usr/local/server/src/function/src/Actions/ValidateBody.php on line 4
it failed because the signature of the method is:
public function __invoke(array $body)
and it failed because I called it passing nothing in the body therefore it's empty and is not an array.
the container
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.
weird...it still shouldn't exit...
I would have expected it to be caught in here: https://github.com/open-runtimes/open-runtimes/blob/a3f20033b642d75096bc9754301e6d1525cebd1e/runtimes/php-8.2/src/server.php#L194-L215
nvm...lol
that's not how to coroutines work...can you create a github issue?
so when the exception is throw I got the following in console:
An internal curl error has occurred within the executor! Error Msg: Connection reset by peer\nError Code: 500
and if I make another request sometimes I will get a time out error and sometimes I get thw following: ```An internal curl error has occurred within the executor! Error Msg: Could not resolve host: 6598662f5ae7b\nError Code: 500 ````
well the crux of the problem is the exception causes the container to crash, but it shouldn't crash
do you have any idea of what I could do as a workaround? I was thinking about looking for a way to assign a global restart policy for those containers (not sure if it's doable)
Maybe you can try to make sure your code doesn't throw an exception
I actually have a try catch inside my function but even Throwable does not seem to catch all errors in PHP
Maybe something in your catch is throwing again?
Recommended threads
- Having issues with login via CLI
``` ~/appwrite appwrite login --endpoint https://localhost/v1 --verbose ? Enter your email myvalidemai...
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...