Skip to content
Back

Function failing with no real explaination

  • 0
  • Functions
f4ls3
2 Feb, 2026, 19:44

⁨```js import {Client, ID, Messaging} from 'node-appwrite';

export default async ({req, res, log, error}) => { if (req.method !== 'GET') return res.json({message: 'Method not allowed'}, 405);

TypeScript
const client = new Client()
    .setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
    .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
    .setKey(req.headers['x-appwrite-key']);

const messaging = new Messaging(client);

await messaging.createEmail({
    topics: ['69781a8c0003xxxxxx'],
    subject: 'Test',
    content: '<h1>Test</h1>',
    html: true,
    messageId: ID.unique(),
});

return res.empty();

};

TypeScript

The execution gets an error: ⁨```Execution timed out.```⁩ but the email is sent correctly??

Im very much confused as to why the return res.empty() would fail??
TL;DR
Function is failing due to timeout even though the email is sent successfully. The issue lies with the return res.empty() call. Try returning a simple JSON response instead of res.empty() to see if it resolves the problem.
f4ls3
2 Feb, 2026, 19:53

Even after adjusting timeout from 15s to 30s it sends the message within the first 10s and the just stays at processing status until it times out

f4ls3
2 Feb, 2026, 19:54

I even tried to use a different response (res.json(...)) and still not responding

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