Skip to content
Back

Function failing with no real explaination

  • 0
  • 2
  • 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 was failing without a clear reason. User swapped runtime from node-16.0 to node-22, which fixed the issue. The starter template worked after deploying.
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

2 Feb, 2026, 23:29

I dont know if I've solved this myself but I have swapped the runtime from the default node-16.0 to node-22 and that seems to have fixed it

2 Feb, 2026, 23:30

Still seems weird to me why this would be the issue 🤷‍♂️

3 Feb, 2026, 03:42

Can you try changing the red empty to something else?

3 Feb, 2026, 07:00

I already tried that

3 Feb, 2026, 07:00

.

3 Feb, 2026, 19:55

How did you create the function? Did you start from a template?

3 Feb, 2026, 19:56

starter template, and i built and deployed it using a gitlab pipeline

3 Feb, 2026, 19:56

and appwrite cli

3 Feb, 2026, 19:57

So did you deploy the starter template and it worked?

3 Feb, 2026, 19:58

starter template worked

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