Back

Functions does not record any logs

  • 0
  • Self Hosted
  • Functions
raizel0609
29 Mar, 2023, 05:07

Still, the first log should be recorded, right? "Log started"

TL;DR
The user is experiencing an issue where their function is not recording any logs. They have made modifications to their code and are using promises correctly. Other users suggest that the issue may be with parsing the payload or an internal error. The user is running the code locally. The error message "Operation timed out" indicates a potential issue with the execution environment. The user is advised to check the logs using `docker compose logs openruntimes-executor`. The lack of logs may be due to exceptions not being properly captured. There is a discussion about the need to parse the payload and the user's frustration with the logs not working. A solution
Christy Jacob
29 Mar, 2023, 05:10

Yeap it should but it's probably getting missed out due to some error

raizel0609
29 Mar, 2023, 05:12

Added the catch. still doesn't work. No logs recorded, and no error recorded either.

Christy Jacob
29 Mar, 2023, 05:12

You should also parse the payload before accessing

raizel0609
29 Mar, 2023, 05:12

Before I do all that, I need to know why the logs doesn't work.

raizel0609
29 Mar, 2023, 05:12

No need to parse payload, or other things. If the logs doesn't work, how do I debug then?

Drake
29 Mar, 2023, 05:13

If an exception is thrown, logs may not be captured properly

Christy Jacob
29 Mar, 2023, 05:14

Logs are a bit patchy at the moment and these are being resolved with the next update to functions. Until then we gotta do some hacking to figure out the issue

raizel0609
29 Mar, 2023, 05:16

I edited the function to only do console.log(), without any import, etc.

raizel0609
29 Mar, 2023, 05:16

The error tabs shows this:

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

raizel0609
29 Mar, 2023, 05:17

Do note, that the error above was not thrown in the previous executions.

Christy Jacob
29 Mar, 2023, 05:17

Are you in Appwrite cloud or running locally?

raizel0609
29 Mar, 2023, 05:17

Locally

Christy Jacob
29 Mar, 2023, 05:17

Okay can you run docker compose logs openruntimes-executor?

Drake
29 Mar, 2023, 05:17

Did you call res.send() or res.json() exactly once before returning?

What exactly was your code?

raizel0609
29 Mar, 2023, 05:19
TypeScript
appwrite-executor  | Executing Runtime: 642290b69993a0d3e9bf-6423c9778fe107c36c6d
appwrite-executor  | [Error] Type: Exception
appwrite-executor  | [Error] Message: An internal curl error has occurred within the executor! Error Msg: Operation timed out
appwrite-executor  | [Error] File: /usr/src/code/app/executor.php
appwrite-executor  | [Error] Line: 544
rafagazani
29 Mar, 2023, 05:20

how was your function after adding the catch?

Christy Jacob
29 Mar, 2023, 05:20

What did your function look like when you got this error?

rafagazani
29 Mar, 2023, 05:25

req.payload is a string, I think it should be converted before calling

rafagazani
29 Mar, 2023, 05:25

I had this same problem in the morning

rafagazani
29 Mar, 2023, 05:27

payload A JSON string containing the data when you created the execution.

raizel0609
29 Mar, 2023, 05:29

So, I figure the problem, I have to return the whole promise. Or else, the function just doesn't work.

Modified code:

TypeScript
return database.listDocuments(
      'DB_ID',
      'COLLECTION_ID'
  ).then((list) => {
    console.log(list.total)
    if (list.total > 0) {
      const doc = list.documents[0]
      res.json(doc)
    }
    
    res.send('Not found')
  })
Christy Jacob
29 Mar, 2023, 05:31

Aah gotcha

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