App.config not loaded upon executing main.es6

Enonic version: 6.15.2

We run some scripts upon starting an application that make use of variables set up in the cfg-file. It seems that these are not available on the global app-object when executing main.es6. Is this by design, or a bug? And if it is the first, is there a work around (e.g. a life cycle event I can hook unto)?

1 Like

Maybe as an extension of this: We’re also using eventListeners in our application, and those are initiated during main.js. It seems that the callback functions never get a correct global app object (name and version are set, but config remains an empty object).

I suspect this may be because how event listeners work behind the hood, i.e. is there some threading where the app-object is copied, and therefore aren’t updated with the “proper” config variables later on? (I don’t actually know how eventLib works behind the hood, so this is pure speculation on my part.)

Just a little extra info, the app object in question during main.js execution:
{
“name”: “no.tine.redacted”,
“version”: “0.0.1”,
“config”: {}
}

What is the sequence of reading config vs. the “application” event like? Could main.js be running before the config file gets parsed? Later in the application execution the config parameters seem to be correctly set.

The application config should be available in main.js . But I just reproduced the problem. It is not set in main.js
when the app is started, but it is there later when accessed via a controller.

I am not sure if it is a timing issue during start up or something else. But looks like a bug. We will look into it.

4 Likes

Any idea when we might see a fix on this?

This will be fixed in the next release. We don’t have a date yet for when that will be.

Here is the issue we registered, in case you want to track its status:

2 Likes

Fix in the release of 6.15.5, released now =)

2 Likes