Logic on Client and Server different (again) - Almost lost code

I’ve reported this happening before, and I think I’ve lost a good bit of code because of this issue (I asked about this in the general slack channel after the outage @mark-piller).

Steps:

  1. I was working on a Cloud Code API
  2. I needed to check and change something in a different API
  3. I used the browser tree (right side of the Cloud Code section) to change to a different API codeless logic
  4. I started making some changes, and went to look for some logic I added yesterday and it was missing.
  5. The logic is on the server, but not being displayed to the client

If I had not noticed this and deployed the code, I would have overwritten my changes from yesterday. This has 100% happened to me in the past and it sucks but I’ve never caught the specifics of how it happened.

If I go into the code from the navigation tree, why would it not load up the most recent version from the server? How do I always force the latest version to make sure I don’t overwrite changes?

Thanks,
Tim

Hello @Tim_Jones,

do you use one computer for work, or perhaps more than one?
Is it possible that you are using the same computer, but different browsers, or are you opening console in incognito mode in parallel?

Regards,
Stanislaw

Hi @stanislaw.grin,

Only one.

I use multiple tabs in Chrome.

No.

I made changes to another cloud code API, went to push my code, and received this notification -

image

I thought it was odd there was an update to the timer. I had made an update this morning but pushed it live already but in a different browser window.

I went over my timer logic, and again the client code was different from the server code.

Had I deployed, I would have lost code again.

It seems like the issue is the client code gets stale when working with multiple tabs. I use multiple tabs to reference or copy and paste code from other APIs. Or I have a data browser tab open to get the column names or one of a hundred other reasons.

In this case I don’t think I went to the timer code in this tab, so why was it trying to deploy that client code up?

It appears that both utils API service and the directFulfillment timer belong to the utils deployment model. In fact, the title of the popup says Deploy utils model.

Deployment models is an extremely important concept in Cloud Code. One of the rules associated with deployment models is that they are deployed as a whole. Meaning you cannot deploy only a part of the deployment model. Instead, the entire model is deployed, even if some parts of it haven’t changed.

Another rule says that when a model is deployed, the version of it that runs in production is removed and replaced by what you deploy.

You can read about the deployment models in the documentation here:
About Deployment Models - Developing Backendless Server Code with node.js

Hope this helps.

Regards,
Mark