Rank 1: Thread
my function for sending email when specific events is triggered is not executed sometimes. sometimes is working properly, i am getting email ...when function is not executed i dont see any error. can someone please help, thanks
Votes
0
Replies
10
Participants
5
Messages
11
Rank 1: Thread
my function for sending email when specific events is triggered is not executed sometimes. sometimes is working properly, i am getting email ...when function is not executed i dont see any error. can someone please help, thanks
I can help! This sounds like a race condition or timing issue where your function sometimes runs before the event data is fully ready, or the event trigger itself is inconsistent.
To diagnose this better: Are you using any specific platform/framework (like AWS Lambda, Firebase, Node.js event emitters, etc.) and what event is triggering the email function?
Rank 1: Thread
i am using appwrite events and here is my function ```import nodemailer from "nodemailer";
export default async ({ req, res, log }) => {
try {
const body = req.body;
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: Number(process.env.SMTP_PORT),
secure: false,
auth: {
user: process.env.SMTP_USERNAME,
pass: process.env.SMTP_PASSWORD,
},
});
await transporter.sendMail({
from: process.env.SMTP_FROM,
to: process.env.SMTP_FROM,
subject: "New Access Created",
html: `
<h2>Nový prístup vytvorený</h2>
<p><strong>Užívateľ:</strong> ${body.userName}</p>
<p><strong>Systém:</strong> ${body.systemName}</p>
<p><strong>Pripojenie :</strong> ${body.connection}</p>
<p><strong>Telefon:</strong> ${body.phone}</p>
<p><strong>Email:</strong> ${body.email}</p>
<p><strong>OrganizationICO:</strong> ${body.ICO}</p>
`,
});
return res.send("Email sent");
} catch (err) {
log(err);
return res.send("Error sending email");
}
};```
I see the problem your function doesn't check if req.body actually has data before sending the email. Sometimes Appwrite sends empty payloads and your function just fails silently.
You need to add validation to check the body data exists before sending.
I can fix this for you and ensure it works reliably. Want to discuss this privately? We can sort it out quickly.
Feel free to DM me!
Hey Steve 👋
Can you provide me your project ID? I can check out logs and error reporting system to see if I can find any match.
Also, for when trigger doesnt happen, is is true that you dont see it in execution list at all?
Rank 1: Thread
project id 68a568df00155ab4407d. yes, e.g today , you see in screenshot one execution(i have got email notification) but i should get at least 4 more email notification
@steve246 this user has been banned. Don't dm anyone that redirects you off the server.
I can only see one error from 22. Jan.
Is there any pattern you noticed with missing executions? I did a bit of digging in DB but couldn't find anything problematic on first sight.
Let me involve few folks here.
TLDR; Event-triggered executions not running, and no execution available in table.
@user This might indicate events not triggering function jobs. I recall edge-case for user creation in $queueForEvents, causing tests to fail. I think that was fixed, but any chance we can have same for document creation or deletion in specific situation?
@user In case this ends up being rare and random, can we do logging improvements, so telemetry has detailed steps, allowing us to understand it when it occurs next?
--
@steve246 Any more insignts on how rare it is, any pattern or ability to reproduce would greatly help too 🙌
Rank 1: Thread
today i've got 3 notifications(see 3 function executions) in the morning but afternoon more than 2 executions missing(no visible, not getting email)will check it for next few days