Exception when App is updated

This seems to happen when the WebApp is left on the login screen and the app is updated on the server.

It then gives this error on the Main Form. its the only form with divHeading in it.

 
Error: Duplicate component name: "divHeading" at Object.Create$1 (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:3634:23) at Object.CreateFmt (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:3641:12) at c.$create (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:366:19) at Object.ValidateRename (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:15533:188) at Object.SetName (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:15513:21) at Object.SetName (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:33680:38) at Object.LoadDFMValues (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:127837:25) at Object.CreateNewForm (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:43375:13) at Object.DoFormLoad (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:43010:12) at XMLHttpRequest.cb (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:282:28)
FMessage
: 
"Duplicate component name: \"divHeading\""
FStack
: 
"Error: Duplicate component name: \"divHeading\"\n    at Object.Create$1 (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:3634:23)\n    at Object.CreateFmt (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:3641:12)\n    at c.$create (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:366:19)\n    at Object.ValidateRename (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:15533:188)\n    at Object.SetName (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:15513:21)\n    at Object.SetName (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:33680:38)\n    at Object.LoadDFMValues (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:127837:25)\n    at Object.CreateNewForm (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:43375:13)\n    at Object.DoFormLoad (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:43010:12)\n    at XMLHttpRequest.cb (https://fleetcommops.com.au/ops-test/ops_1_0_2109.js:282:28)"
[[Prototype]]
: 
Object
  1. Any idea what might be happening.
    • Its not double clicking of the buttons, I have already catered for that by disabling the button on press.
    • It also happens on my browsers when left on the login page.
  2. Any suggestions on mitigating it, it freaks the Client out.

If the app was updated on the server, the sensible thing to do is restart the app, i.e. by doing a refresh from the browser.

I know. But that sounds like an excuse to the client. I wanted to know what could be causing that error? How could it be creating the mainform the second time... so that I can detect it and do something.

Do these sound like a good idea?

  • In the webapp : Detect the version of the js by reading the index.html and auto-restarting
  • On the server : Detect and the WebApp queries it periodically and auto-restarts
  • On the webapp - if its on the logon screen, just restarting once every 5 minutes or so

If you really want to do safe updates and not have any running apps interrupted, deploy to a new versioned folder name. Only upon restart / refresh, redirect to the new folder.
Otherwise, it can always happen a user wants to access in the middle of an update and fetch a mix of updated and not updated files with unpredictable results.

Finally I can duplicate this. It wasn't because of updates.

I have an Exit menu, which loads the URL for the landing page on the website, which is a different WebApp. Here the user can select Which "WebApp" they want to run, depending on what their role is in the organisation.

  • The user clicks Exit
  • They are taken to the main page (different WebApp)
  • The select this app again
  • It fails every time.

So my guess is that the Browser has loaded the last memory image (Data Memory) of it, but the WebApp runs from the beginning. It creates the Main form and the name of the first component on the form already exists.

I have tried putting try except in various places to catch it and do a reload. But I haven't succeeded.

Questions

  • Does anyone have any suggestions on how I can detect this situation.
  • Alternatively, is there a way to clean up the memory before I go to the landing page.

I am already closing the main form

procedure Tfrm_Ops_Main.Exit_Application;
begin
  Close;
  THtml.Change_Page (url_Landing_Page);
end;

The problem was with the Log_Out method. I was doing a Reload, assuming that everything would be fine.

It turns out that browser does not clear the memory. And the javascript garbage collector hasn't had a chance to run.

Now that I am freeing the childform and doing a Close, the problem is cured.

procedure Tfrm_Ops_Main.Log_Out (AAuto : Boolean = False);
begin
  TConsole.Log ('Logging Out');
  if AAuto
  then THtml.Allow_Tab_Close;
  Free_Child_Form;
  Close;
  THtml.Reload_Page;
end;
1 Like