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 Auth & Function don't reveal cl...
When I execute a function or sign in with my Flutter app, Appwrite does not show my real IP: instead, it seems that Appwrite shows Fastly CDN IP address.
- All function deployments fail (node 18-2...
Error: bash: /usr/local/server/helpers/build-cache.sh: No such file or directory Sidecar error: Build archive was not created at /mnt/code/code.tar.gz Scope: ...
- Why does this happen?
`AppwriteException: general_argument_invalid, Invalid `secret` param: Value must be a valid string and at least 1 chars and no longer than 256 chars (400)` the...