-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 Bug Report: Function execution failed. #5423
Comments
@usamashafiqs thanks for creating this issue! 馃檹馃徏 This typically happens due to an error from your function code. Please try to make sure your code doesn't throw any errors (you can wrap all your code in a big try/catch and call This could also be a true timeout. One way to tell is if your function's execution time is consistently the same as the timeout configured for your function. If this is the case, you should increase the timeout on the function. |
@stnguyen90 I wrap my code with try/catch and increase the timeout as well still getting the same error.
appwrite-executor logs
This code is working on local appwrite instance but not on ec2 or linode instances. |
@usamashafiqs, some more questions:
|
@stnguyen90, because I set the timeout value to 60, it took 60 seconds. const nodemailer = require('nodemailer');
module.exports = async function (req, res) {
try {
const transporter = nodemailer.createTransport({
host: req.variables.HOST,
port: req.variables.PORT,
secure: req.variables.SECURE,
auth: {
user: req.variables.USER,
pass: req.variables.PASS,
},
});
const payload = JSON.parse(req.payload);
const name = payload['name'];
const email = payload['email'];
const subject = payload['subject'];
const text = payload['text'];
const info = await transporter.sendMail({
from: `"Sender" <${req.variables.USER}>,`, // Sender email
to: `"${name}" <${email}>,`,
subject: subject,
text: text,
});
res.json({
message: 'Email sent successfully',
emailId: info.messageId,
});
} catch (e) {
res.send(e);
}
}; |
@usamashafiqs this could be a true timeout and because it times out, Appwrite isn't able to capture the logs. Would you please increase the timeout? In addition, instead of calling |
Same Error:
|
@stnguyen90 I think function is not doing async tasks. When I try to execute a simple fetch request within a function got this error.
|
see #4594 , try catch and return |
@usamashafiqs, please share your full code. |
nodemail.tar.gz |
Oh my god, after searching a lot in the documentation and github I have seen that each function has a time limit that is specified in its configuration: https://appwrite.io/docs/functions#:~:text=Each%20execution%20has%20a%20default,for%20up%20to%20900%20seconds. @usamashafiqs I think this can help you |
Yes there is a timeout for functions. @usamashafiqs did knowing this help you? |
The In addition, it's odd the stack trace doesn't quite line up with the code. The stack trace says the error occurred on line 55, but your file is less than 55 lines. |
@stnguyen90 The stack trace of the current code is:
I try to execute a simple fetch request within a function got this stack trace.
They both are different, but they are doing async tasks. I think the problem is that Function is not doing async tasks. |
Would you please share your latest full code for this function so I can see what's on line 55 that's throwing the error?
Async code works fine in Appwrite functions. |
@usamashafiqs, are you still facing this problem? FYI, I'll need to close this due to inactivity soon. |
If you are using Appwrite locally on your computer, you may have problems connecting to the API. In my case, replacing the localhost address in the endpoint with the IP address of my computer helped. Do not use "http:https://localhost/v1" or "http:https://127.0.0.1/v1" when calling Appwrite API FUNCTIONS if the server is running locally. Instead, specify the actual IP address of your machine in the ENDPOINT. I spent two days figuring out this problem. I hope my experience will help someone save time and avoid headaches due to the wrong endpoint. |
馃憻 Reproduction steps
On localhost this is running fine but not on ec2 instance.
Executions Logs
Appwrite-executor Logs
Code
馃憤 Expected behavior
Function execution should be fine.
馃憥 Actual Behavior
Function execution failed.
馃幉 Appwrite version
Version 1.3.x
馃捇 Operating system
Linux
馃П Your Environment
No response
馃憖 Have you spent some time to check if this issue has been raised before?
馃彚 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: