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
is the package in your package.json? In your function settings, do you have npm install set?
So here's how my functions/ai_generate/package.json looks like
{
"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"
}
}
And then functions/ai_generate/src/main.js contains my function execution code
And also the function is being deployed successfully
This is my Appwrite Console Functions Settings
And yes the npm install is set in the functions settings of Appwrite
Has your function ever worked? How did you create it? How are you deploying? What are the function path settings?
Nope it was not working since beginning
I created it from the Appwrite Console
And deploying from git
Functions path settings are automatically configured from the git one
<@788512672748535808> See I eliminated this error
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)
But now facing this one
Synchronous function execution timed out. Use asynchronous execution instead, or ensure the execution duration doesn't exceed 30 seconds.\nError Code: 408
Steven if you want I can share you the link of my GitHub Repo (it's private)
So I can share you the invitation link there
Recommended threads
- Appwrite-injected variables are not avai...
I am using rust-1.83 as a runtime and try to access APPWRITE_FUNCTION_API_ENDPOINT or APPWRITE_FUNCTION_API_KEY during runtime. Both are not set during my execu...
- Custom domain for Google Auth
Hello! I connected my custom domain to my Appwrite project, but I can't get the Google login/consent screen to show my domain instead of the Appwrite domain. I...
- CLI - get Database Totals
Is there a way with the Appwrite CLI to get table row totals (count)❓