Application variables created within runAsync are not defined after runAsync completes

Hi, I am trying refactor a CF18 legacy code that does initialization and creating all application variables but including those templates that handles creation of application variables doesn’t seem to exist after runAsync completes. Anybody know why application variables created inside runAsync are not defined/created once future is complete and workaround is available?

Below is the code I have tried and confirmed that application variables are created and visible in CF18 but not in Lucee.

<cfscript>
	future = runAsync(function(){
	application.out1 = "vertical line";
		return 10;
	}).then( function(input){
		application.out2 = "vertical line2";
		return input + 20;
	});
	writedump(application);
	writedump(future);
	result = future.get(10); // 10 is timeout(in ms)
	writeOutput(result); // output is 30
</cfscript>

@Eymard_Ventura related ticket from Jira: [LDEV-3833] - Lucee

Using cfapplication action="update" name="Your_Application_Name" inside runAsync() worked for me. Please try this workaround. But note this workaround works for application variables and it does not work for the application configuration (likes mappings, mailServers).

future = runAsync(function(){
    cfapplication(action="update", name="Your_Application_Name");
    application.out1 = "vertical line";
    variables.rest = application.restout;
    return 10; }).
then(
    function(input){
        cfapplication(action="update", name="Your_Application_Name");
        application.out2 = "vertical line2";
    return input + 20;
}); 
writedump(application);
writedump(future); 
result = future.get(10);

Thank you so much @cfmitrah! Yes I noticed mappings in Application.cfc needed to be created via administrator API.

OMG so glad I found this! I have been trying to get runAsync to work with queries for the last few hours and no joy.

When no datasource set it does not find the default dataset:

Attribute [datasource] is required when attribute [dbtype] is not [query] and no default datasource is defined

and, similarly, when I set the datasource it fails to find it. This makes sense because application scope is a new variable not from the original context.

It seems to be a regression noticed a year ago and is in the backlog.

Any1 know when this is going to be fixed? Sadly, server level mappings and datasources are not a workaround we can use.