Back

[SOLVED]Appwrite cloud functions failing on creating Executions with the client sdk

  • 1
  • Functions
  • Web
  • Cloud
bigsam
24 Sep, 2023, 20:11

i was trying to use appwrite cloud functions with my next.js project, using the client sdk and i was getting this error from my appwrite function execution tab

TL;DR
Summary: Appwrite cloud functions were failing on creating executions with the client SDK. The issue was caused by selecting an incorrect main file while deploying through Git. The error message indicated that the code file could not be loaded, and it mentioned the specific file path. The solution was to use server-side SDKs for Appwrite Cloud Functions and make sure the functions followed the custom structure. Client-side SDKs should not be used in the function. The user was trying to use Appwrite cloud functions with a Next.js project and encountered the error in the function execution tab. Solution: Use server-side SDKs for Appwrite Cloud Functions and ensure the
D5
24 Sep, 2023, 20:14

Are you using client side SDK in the function? 👀

bigsam
24 Sep, 2023, 20:17

yes…i am using the client side sdk in the function

https://appwrite.io/docs/client/functions

D5
24 Sep, 2023, 20:18

You can't/shouldn't

D5
24 Sep, 2023, 20:19

Also functions need to follow a custom structure

D5
24 Sep, 2023, 20:19
safwan
25 Sep, 2023, 04:40

As D5 mentioned, you must always use Server-Side SDKs for Appwrite Cloud Functions.

Functions are run on the server-side either with an API key or a JWT.

bigsam
25 Sep, 2023, 15:59

i have tried to run from server-side now but here's the error i am getting trying to execute my functions from Appwrite cloud

TypeScript
Error: Cannot find module '/usr/local/server/src/function/src/main.js'
Require stack:
- /usr/local/server/src/server.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25)
    at require (node:internal/modules/cjs/helpers:102:18)
    at execute (/usr/local/server/src/server.js:123:28)
    at /usr/local/server/src/server.js:158:33
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)```
D5
25 Sep, 2023, 16:08

How are you deploying the function ?

D5
25 Sep, 2023, 16:08

I recommend through CLI

bigsam
25 Sep, 2023, 16:09

i am deploying through Git

bigsam
25 Sep, 2023, 16:14

was the above error caused by using the Git to deploy?

D5
25 Sep, 2023, 19:27

Usually not, but selected an incorrect main file

D5
25 Sep, 2023, 19:27

Or it's not readable/faulty

bigsam
26 Sep, 2023, 16:44

okay…thanks @D5 and @safwan i think it’s been solved already

bigsam
26 Sep, 2023, 16:47

[SOLVED]Appwrite cloud functions failing on creating Executions with the client sdk

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