
hi!
i found a strange behaviour in my function logs:
i noticed there is a log ouput twice in one execution. <here should be the attached screenshot> .. hmm 🤔
but the code is not inside of an iteration:
TypeScript
// Perform all your imports
const sdk = require('node-appwrite');
// Initialise the client SDK
module.exports = async function (req, res) {
if (req.variables.APPWRITE_FUNCTION_TRIGGER == 'schedule') {
return;
}
const client = new sdk.Client();
client
.setEndpoint(req.variables.APPWRITE_FUNCTION_ENDPOINT)
.setProject(req.variables.APPWRITE_FUNCTION_PROJECT_ID)
.setJWT(req.variables.APPWRITE_FUNCTION_JWT)
.setSelfSigned(true);
const admClient = new sdk.Client();
admClient
.setEndpoint(req.variables.APPWRITE_FUNCTION_ENDPOINT)
.setProject(req.variables.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(req.variables.APPWRITE_FUNCTION_API_KEY)
.setSelfSigned(true);
// Initialise the SDK
let db = new sdk.Databases(client);
let users = new sdk.Users(admClient);
//user that is logged in
let userId = req.variables.APPWRITE_FUNCTION_USER_ID;
if (userId == null || userId == "") {
console.log("No user");
return;
}
let user = await users.get(userId);
userName = user.name;
userMail = user.email;
let nowDate = new Date(Date.now());
console.log(`User ID: ${userId} - ${userName} (${userMail})`); //<--- output line 1 / and 3 ??
console.log(`Started: ${nowDate.toDateString()} ${nowDate.toTimeString()}`); //<--- output line 2 / and 4 ??
...
TL;DR
Developers discovered a log output occurring twice in a function, even though it's not within an iteration. Upon review, they found that the code snippet provided might be executing twice due to a potential issue in the function's logic.Recommended threads
- incrementDocumentAttribute throwing "Rou...
Hi, I’m running into an issue when trying to increment a numeric field using the Node.js SDK. My environment: Appwrite: self-hosted, version 1.7.4 node-appwrit...
- Why can't I sign up on whitelisted email...
I’m trying to sign up in the Appwrite console using a whitelisted email address, but it doesn’t work. What happens: Sometimes I get “User already exists” for ...
- Appwrite 1.7.4 Docker query error
I’m running Appwrite 1.7.4 docker image using the sdk-for-apple package. The collection has 16 documents if l run Query.limit(1) I get one record. But if I run ...
