Skip to content
Back

Functions Problem

  • 0
  • 3
  • Functions
  • Cloud
Arhan Ansari
24 Jan, 2026, 09:21

Whenever I run my AI Generate through Appwrite Functions, I am getting this Call Stack AIService.generateServer (src\services\ai\gemini.ts) next (<native>) asyncGeneratorStep (node_modules@babel\runtime\helpers\asyncToGenerator.js) _next (node_modules@babel\runtime\helpers\asyncToGenerator.js) tryCallOne (address at (InternalBytecode.js:1:1180) anonymous (address at (InternalBytecode.js:1:1874) This is my terminal one Could not load code file. Error: Cannot find module '/usr/local/server/src/function/src/main.js' Require stack:

  • /usr/local/server/src/server.js at Function._resolveFilename (node:internal/modules/cjs/loader:1383:15) at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19) at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22) at Function._load (node:internal/modules/cjs/loader:1192:37) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:237:24) at Module.require (node:internal/modules/cjs/loader:1463:12) at require (node:internal/modules/helpers:147:16) at execute (/usr/local/server/src/server.js:185:22) at action (/usr/local/server/src/server.js:237:27) This is my execution log
TL;DR
Created function in Appwrite Console and deployed from Git, functions path automatically configured from Git. Fixed "Could not load code file" error. Facing new error "Synchronous function execution timed out. Use asynchronous execution or ensure duration doesn't exceed 30 seconds." Offered to share GitHub Repo link for further assistance.
26 Jan, 2026, 19:20

is the package in your package.json? In your function settings, do you have npm install set?

27 Jan, 2026, 06:09

So here's how my functions/ai_generate/package.json looks like

TypeScript
{
  "name": "ai-generate",
  "version": "1.0.0",
  "description": "Appwrite Function to generate content using Gemini AI",
  "main": "src/main.js",
  "type": "module",
  "dependencies": {
    "node-fetch": "^3.3.0"
  },
  "engines": {
    "node": ">=18.0.0"
  }
}
27 Jan, 2026, 06:10

And then functions/ai_generate/src/main.js contains my function execution code

27 Jan, 2026, 06:10

And also the function is being deployed successfully

27 Jan, 2026, 06:14

This is my Appwrite Console Functions Settings

27 Jan, 2026, 06:15
27 Jan, 2026, 06:16

And yes the npm install is set in the functions settings of Appwrite

27 Jan, 2026, 21:56

Has your function ever worked? How did you create it? How are you deploying? What are the function path settings?

28 Jan, 2026, 05:56

Nope it was not working since beginning

28 Jan, 2026, 05:56

I created it from the Appwrite Console

28 Jan, 2026, 05:56

And deploying from git

28 Jan, 2026, 05:56

Functions path settings are automatically configured from the git one

28 Jan, 2026, 05:59

<@788512672748535808> See I eliminated this error

TypeScript
Could not load code file.
Error: Cannot find module '/usr/local/server/src/function/src/main.js'
Require stack:
- /usr/local/server/src/server.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1383:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
    at Function._load (node:internal/modules/cjs/loader:1192:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
    at Module.require (node:internal/modules/cjs/loader:1463:12)
    at require (node:internal/modules/helpers:147:16)
    at execute (/usr/local/server/src/server.js:185:22)
    at action (/usr/local/server/src/server.js:237:27)
28 Jan, 2026, 05:59

But now facing this one

28 Jan, 2026, 05:59
TypeScript
Synchronous function execution timed out. Use asynchronous execution instead, or ensure the execution duration doesn't exceed 30 seconds.\nError Code: 408
28 Jan, 2026, 06:00

Steven if you want I can share you the link of my GitHub Repo (it's private)

28 Jan, 2026, 06:00

So I can share you the invitation link there

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