Vercel not executing all actions
Unanswered
Collared Plover posted this in #help-forum
Collared PloverOP
Hey, I'm having problems with Vercel. It does not perform all the actions, but when I try it 3/4x it eventually works.
For example, I have this server-side function that sends emails using node mailer, sometimes it sends the email, and in some cases I've got to run the action a few times. But I'm having the same problem with many other server-side functions. A few months ago we thought it was due to the "serverless function maximum execution duration", but that seems strange to me as the functions are instantaneous on my Macbook using wireless internet. So I doubt that a host that is supposed to be fast and optimised for this sort of thing would take longer than 10s (from the hobby plan) to perform these actions.
For example, I have this server-side function that sends emails using node mailer, sometimes it sends the email, and in some cases I've got to run the action a few times. But I'm having the same problem with many other server-side functions. A few months ago we thought it was due to the "serverless function maximum execution duration", but that seems strange to me as the functions are instantaneous on my Macbook using wireless internet. So I doubt that a host that is supposed to be fast and optimised for this sort of thing would take longer than 10s (from the hobby plan) to perform these actions.
// Action.js
'use server'
import nodemailer from 'nodemailer';
export async function handleSubmit(currentState, formData) {
if(formData.get('password') !== 'dmca@Arix'){
return 'password';
}
const transporter = nodemailer.createTransport({
pool: true,
host: "web01.HIDDEN.net",
port: 587,
secure: false, // use TLS
auth: {
user: "HIDDEN@example.one",
pass: "HIDDEN",
},
});
const mailOptions = {
from: 'legal@weijers.one',
to: formData.get('reportEmails') + ', legal@weijers.one',
subject: `DMCA Takedown request`,
replyTo: 'legal@weijers.one',
text: formData.get('body')
}
try {
transporter.sendMail(mailOptions);
return await 'success';
} catch (error) {
return 'error';
}
}6 Replies
transporter.sendMail(mailOptions);
return await 'success'; this is your problem
every async operation must be explicitly awaited in a serverless function
or you will introduce race conditions
await transporter.sendMail(mailOptions);
return `success`;Collared PloverOP
What about this file @linesofcode, the same issue?
'use server'
import { getLicense } from "@/libs/getLicense";
const Webhook = async (message) => {
await fetch('https://discord.com/api/webhooks/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: message
})
})
}
export async function handleSubmit(currentState, formData) {
if(formData.get('privacypolicy') !== 'on'){
return 'privacypolicy';
}
Webhook(`## :gear: Register report
**Status**: Pending...
**Reported by**: <@${formData.get('discord')}>
**Panel**: <https://${formData.get('panel')}>
[\` Takedown panel ↗ \`](<https://arix.gg/verify-license/dmca/${formData.get('panel')}>)
`);
const license = await getLicense(formData.get('panel'));
if(license == 'CloudFlare recognized'){
Webhook(`## :warning: New report
**Status**: CloudFlare
**Reported by**: <@${formData.get('discord')}>
**Panel**: <https://${formData.get('panel')}>
[\` Takedown panel ↗ \`](<https://arix.gg/verify-license/dmca/${formData.get('panel')}>)
`);
}
if(license == 'Leak recognized'){
Webhook(`## :warning: New report
**Status**: Using leak
**Reported by**: <@${formData.get('discord')}>
**Panel**: <https://${formData.get('panel')}>
[\` Takedown panel ↗ \`](<https://arix.gg/verify-license/dmca/${formData.get('panel')}>)
`);
}
return license;
}