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
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...