App.Array() contents are different?

I have a simple test web app that uses HandleURL to listen for API requests and to pass off a no path request to the framework to display a web page. HandleURL appends to App.Array() a message for all requests coming into the app.

For API requests the response contains the contents of App.Array(). The main web page has a listbox that populates with the contents of App.Array().

What I find to be unexpected behavior is that the contents of App.Array() are different in the API response than they are in the web page listbox. Is App.Array() not the same object in the session as it is at the App level?

Can you post the sample app?

Are you seeing this behavior in the IDE/dev environment, or in the deployed app? In a hosted solution you may see two (or more) instances of App, and each has its own silo of data - so sending a URL request into your solution may be hitting one instance, where the data your seeing in your Session/WebPage may be hitting another instance. Just a thought.

In a Web app, the App() should be a single instance shared across all WebSessions. Sessions, however, do not share data, as there will be one session per browser window[*]

@William_Reynolds makes a good point about hosted solutions which may run more than one copy of your app.

  • actually, one session per browser window per reload - e.g. if you have 2 browser windows, and hit Reload on both, you will end up creating 4 sessions total, with 2 of the sessions closing due to the reload.

This sounds about right. The app is running on Xojo Cloud and there is really no overlap in the contents of App.Array() when reporting from the the web page and from the API.

Xojo Cloud will launch one instance for each CPU available on your plan. You can synchronize data between them with a file on disk and SQLite works great for this.

Thanks Tim. Being a little test app I went with the array as the simplest way to log stuff. The real app will be using a DB to handle all the logging.