Yes, there was a restart between the errors.
maybe try redeploying?
The function has been updated and adjusted for 1.3.0. But the result is the same :/
Have you tried deleting the variables and adding them back?
Just tried that, but has no impact.
Can I be sure, that the error is located within the read of the environment variable or can it also be an issue on the MongoDB side?
I just looked for a function, where I didn't use the MONGODB_USER. I get the same error for an other environment variable with the same error message. So in conclusion it shouldn't be related to the MongoDB connection.
The stack trace seems to indicate it's req.variables problem.
What's docker ps show?
What exactly should be expected? The Function Container are listed.
all the appwrite containers and their versions...
would you please make sure to show the container names?
Hope it is readible
can you check the docker logs for the appwrite-executor and appwrite-worker-functions containers to see if there are any errors/warnings?
appwrite-executor:
could you also try updating your code to do this at the beginning:
res.json(req);
return;
docker logs 630f8d82d13133b826cc-6452b553edb419672a03
import { Client, Account } from 'node-appwrite';
module.exports = async function (req: any, res: any) {
const client = new Client();
if (!req.variables['APPWRITE_FUNCTION_ENDPOINT'] || !req.variables['APPWRITE_FUNCTION_API_KEY']) {
console.warn('Environment variables are not set. Function cannot use Appwrite SDK.');
} else {
client
.setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT'])
.setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID'])
.setJWT(req.variables['APPWRITE_FUNCTION_JWT'])
.setSelfSigned();
}
const account = new Account(client);
let promise = account.get();
promise.then(
function (response) {
let userId = response.$id;
},
function (error) {
console.log(error); // Failure
}
);
async function run() {
try {
//Create Response
res.json(req);
return;
} catch (error) {
console.log('Error parsing JSON:', error, req.payload);
} finally {
}
}
run().catch(console.dir);
};
Is this sufficient (after compiling to JS)?
ideally, you would compile and deploy:
module.exports = async function (req: any, res: any) {
res.json(req);
}
in the same function as your previous one
I think i found the problem...
let me see how fast we can fix this
I tried today your minimal function. It worked fine. After that all the functions worked fine as well. There was another restart between the tests, so I am not sure what cured the error. I am unable to reproduce my error, but for now it works fine again. It would be nice, if the error could be scrutinized, because otherwise my app would have unexpected downtime, once I go to production.
Ya...sorry, we had a problem with our runtime image
No reason to be sorry about.😉 I very much appreciate the dedication you guys put into the project and also your quick help and support. Thanks a lot for that! <:appwriteheart2:1073243188954935387> 🙂
Recommended threads
- Cannot update existing function to Dart ...
I can only select up to Dart 3.10.
- Function executions not getting logged b...
Hello, I have just upgraded on a self-hosted 1.8.1 to 1.9.0 and I have a strange bug where my functions are no longer showing executions in the console, howeve...
- Cloud Function Deployment Issue – Timeou...
Impossible to deploy a function for more than an hour. My project ID is: 69cc7a82000b42b8f5e2 Here's the error I get after waiting 15 minutes: Synchronous funct...