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] runAsync does not capture the surrounding PageContext - 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.