Back

An internal curl error has occurred within the executor! Error Msg: Operation timed out

  • 0
  • Self Hosted
mauricev
23 Sep, 2023, 04:00

I assigned the API_KEY variable in a file and uploaded it to the function. I did this just once. Every time I make a change to index.php, I create a deployment on the command line of my Mac, and it shows up as a new active deployment. I then execute the function by clicking the Execute Now button. If the prior execution failed, this one will succeed. Then the next one will fail, ad infinitum. So it appears that appwrite has a memory across function executions, and it passes the API_KEY variable on every other execution only.

TL;DR
The user is experiencing an "internal curl error" with a timeout message. They have tried running the script under cron where it worked, and they plan to upgrade to 1.4.x in the future. Another user suggests removing a duplicate function declaration as a potential solution. The user also encounters a different issue where the presence of an empty function in the code determines the success or failure of executions. The empty function causes cyclical failures, but commenting it out or completely removing it allows the script to always run. The user suspects an issue with the PHP interpreter inside Appwrite. Further discussion reveals that the user's API_KEY variable is
Drake
23 Sep, 2023, 04:10

You mean you're uploading a .env file?

What command are you running to deploy the function?

mauricev
23 Sep, 2023, 04:12

I "imported" an .env file. I did that at the initial creation of the function. The command I used to deploy the function is appwrite functions createDeployment --functionId=650d12f2bf31e2ea6fba --entrypoint='index.php' --code="." --activate=true

Drake
23 Sep, 2023, 04:19

API_KEY isn't false, right? It's not set at all?

mauricev
23 Sep, 2023, 04:21

I have it set to the password I use for my appwrite account. It's also the value of the openssl key. All three are the same value.

Drake
23 Sep, 2023, 04:22

I mean when it fails, it's not set to false, right?

Drake
23 Sep, 2023, 04:24

If you log $req['variables'], it's either an empty array or an array with variables?

mauricev
23 Sep, 2023, 05:28

All the variables are there. That's not the cause. If I put in this function ```function returnAllTheTanks($api_key) { //$q = new Query();

TypeScript
    //$tankQuery = [ $q->equal("facility_fk",'64bdd24440f7ab4908db'),$q->limit(5000)]; // 64bdd24440f7ab4908db is facility document id (not facility collection)

    //return queryDocument('6408223c577dec6908e7', $tankQuery, $api_key); // 6408223c577dec6908e7 is tank collection id
}``` where I have an empty function body because that’s commented out, I get the cyclical failing. If I totally comment out this function, it always runs,  so it appears there's something going on with php interpreter inside appwrite that is triggering these failures.
VincentGe
23 Sep, 2023, 13:59

how long do the successes and failures take? I wonder if it actually could be timing out

VincentGe
23 Sep, 2023, 14:00

@Steven could this mean one of ur many workers and DBs are flakey?

Drake
23 Sep, 2023, 15:53

Oh this is different than what you mentioned before...So what's the full code that's failing now?

Drake
23 Sep, 2023, 15:54

Maybe...but probably not 🧐

mauricev
23 Sep, 2023, 20:32

Whether a given execution fails or succeeds is 100% dependent on what the last execution did. Last execution failed; the upcoming will succeed Last executions succeeds; the upcoming will fail

The following code triggers this type of behavior

TypeScript
<?php

require 'vendor/autoload.php';

use Appwrite\Client;
use Appwrite\Services\Databases;
use Appwrite\Query;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

 
return function ($req, $res) {

    function returnAllTheTanks($api_key) {
        
    }

   $res->json([
        'message' => 'Did I pass!',
    ]);

    }
?>

The mere presence of the empty function

TypeScript
function returnAllTheTanks($api_key) {
        
    }

is a deciding factor. Take it out and the function will always succeed.

Drake
23 Sep, 2023, 20:42

Thanks for this. I'll try to reproduce the problem with this

VincentGe
24 Sep, 2023, 02:58

That's bizarre! so curious why this changes anything

Drake
18 Oct, 2023, 16:01

apologies for the delay. did you figure out the problem? Have you tried using the new 1.4 syntax?

Drake
18 Oct, 2023, 16:03

in 1.4, i initialized a starter function using the CLI and modified it as such:

TypeScript
<?php

require(__DIR__ . '/../vendor/autoload.php');

use Appwrite\Client;

// This is your Appwrite function
// It's executed each time we get a request
return function ($context) {
    function returnAllTheTanks($context) {
        $context->log('inside returnAllTheTanks!');
    }

    returnAllTheTanks($context);

    // You can log messages to the console
    $context->log('Hello, Logs!');

    // If something goes wrong, log an error
    $context->error('Hello, Errors!');

    // The `req` object contains the request data
    if ($context->req->method === 'GET') {
        // Send a response with the res object helpers
        // `res.send()` dispatches a string back to the client
        return $context->res->send('Hello, World!');
    }

    // `res.json()` is a handy helper for sending JSON
    return $context->res->json([
        'motto' => 'Build like a team of hundreds_',
        'learn' => 'https://appwrite.io/docs',
        'connect' => 'https://appwrite.io/discord',
        'getInspired' => 'https://builtwith.appwrite.io',
    ]);
};

and it worked fine

Drake
18 Oct, 2023, 16:03
mauricev
26 Oct, 2023, 01:38

Sorry, I am still using 1.3.7. I just run the script twice. Once the users are comfortable with my app, which I just rolled out, I'll plan to upgrade to 1.4.x.

Drake
8 Nov, 2023, 00:55

Are you still having problems with the function?

mauricev
8 Nov, 2023, 01:05

It's actually been working under the cron schedule on 1.3.7.

Drake
8 Nov, 2023, 01:06

How'd you solve the problem?

mauricev
8 Nov, 2023, 01:07

I didn't. It appears under cron, it works. I haven't tested it manually since.

Drake
8 Nov, 2023, 01:08

Actually, I just found this post about how you can't declare a function twice 🧐

https://stackoverflow.com/questions/1631535/function-inside-a-function

Maybe that's the problem

Drake
8 Nov, 2023, 01:09

Maybe it works via schedule because the runtime container is actually shut down between executions

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