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
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...
- Our Appwrite organization is suspended
Please give support regarding this , no app is working now , please solve my issue and give support , no one is replying in message section or email.
- 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...