
Hi.
Here's what's being happening to me with cloud functions.
So, I have some test cloud function that returns some json data.
When I change my function file locally and run appwrite deploy function
command, it deploys a code that was previously in the file, not the latest version.
If I run the command again, it will deploy the latest version I have.
For some reason I have to make two deployments in order to make latest one actually being deployed.
Has anyone experienced this?

const sdk = require("node-appwrite");
/*
'req' variable has:
'headers' - object with request headers
'payload' - request body data as a string
'variables' - object with function variables
'res' variable has:
'send(text, status)' - function to return text response. Status code defaults to 200
'json(obj, status)' - function to return JSON response. Status code defaults to 200
If an error is thrown, a response with code 500 will be returned.
*/
module.exports = async function (req, res) {
const client = new sdk.Client();
// You can remove services you don't use
const account = new sdk.Account(client);
const avatars = new sdk.Avatars(client);
const database = new sdk.Databases(client);
const functions = new sdk.Functions(client);
const health = new sdk.Health(client);
const locale = new sdk.Locale(client);
const storage = new sdk.Storage(client);
const teams = new sdk.Teams(client);
const users = new sdk.Users(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'])
.setKey(req.variables['APPWRITE_FUNCTION_API_KEY'])
.setSelfSigned(true);
}
res.json({
req: req.variables['APPWRITE_FUNCTION_API_KEY'],
env: process.env.TEST,
hello: 'World'
});
};
This is the function whole code and only changes I am currently making is inside res.json just to see different outputs in the logs

Did you have selected the function when deploying?

I mean, selected it with the space bar

Yes

Then not sure

You're using visual studio code?

Yeah

I can maybe make a one minute video if needed

Then not sure what could be happening. I'm using VS code without inconveniences. Maybe you didn't saved the file previously? I think it's not probably, but just in case š

I did save it

I supposed š¬

Then not sure what's happening

These are the steps I do
- Make a change in my index file and save it
- make a deployment
- deployment gets in the appwrite console and I activate that deployment
- I run execution
- In logs I see the data format from previous version
- I run deployment again without any code changes
- I activate deployment in the console
- I run the execution
- Latest data format is now shown in the logs

Update.
I tried to deploy a second function.
First time deployment - I saw it being built inside appwrite console as it was being deployed and it disappeared after 2 seconds.
Then I had to run deploy command again to deploy it.
š¤·

deployment gets in the appwrite console and I activate that deployment
I think it gets activated automatically so you may be activating the old one

I click to activate the latest one I see built in the console, I didn't know it's automatic

That seems to be the problem

You're activating the old one

Ah it seems I actually was. š
Sory, all good then.

[SOLVED] Function deployment deploys older deployment in the appwrite cloud
Recommended threads
- User (role: guests) missing scopes (["te...
I keep getting this error: ```AppwriteException: User (role: guests) missing scopes (["teams.read"]) at new AppwriteException (/usr/local/server/src/functio...
- I got arhcived project, but I didn't it
Hello, help me please, I can't use my main project in appwrite
- Queries Length Error.
Hi All, I am having a issues across my app with how i am getting data, and just wanted to check if this was an issues with the new changes on appwrite over the...
