Skip to main content
Ben Nadel at InVision In Real Life (IRL) 2018 (Hollywood, CA) with: Joel Hill
Ben Nadel at InVision In Real Life (IRL) 2018 (Hollywood, CA) with: Joel Hill

Adobe ColdFusion Bug: Nested Array Iteration Breaks Closure Variables

By
Published in Comments (3)

While working on my Big Sexy Poems app (GitHub), I ran into another wild bug in Adobe ColdFusion (see previous post). I don't exactly know how to articulate this one; but, it seems that if I perform nested array iteration within the context of an asynchronous array iteration, closed-over variables are no longer available within a closure scope.

This breaks in both Adobe ColdFusion 2021 and 2025 with the same error. Here's my reproduction code:

<cfscript>

	// ASYNCHRONOUS array iteration.
	arrayEach(
		[ "" ],
		() => foo( 999 ),
		true
	);

	public array function foo( required numeric flag ) {

		return arrayFilter(
			bar(),
			( result ) => flag // BUG: This closed-over variable is UNDEFINED!
		);

	}

	public array function bar() {

		return arrayFilter( [ "" ], ( element ) => true );

	}

</cfscript>

There are three layers of iteration happening here:

  1. The asynchronous iteration that kicks of the demo.
  2. The arrayFilter() in foo().
  3. The arrayFilter() in bar().

When I run this in Adobe ColdFusin 2021/2025, it breaks with the following error:

coldfusion.runtime.UndefinedVariableException:

Variable FLAG is undefined.

I can remove the error by either:

  • Changing from asynchronous to synchronous iteration in the first arrayEach() call. But, this only fixes the issue in ACF 2025 - the error persists in ACF 2021.

  • Removing the arrayFilter() in bar(). For example, if I just return the array literal, [""], which is what the deeply nested array iteration was creating, it fixes the issue in both ACF 2021 and ACF 2025.

This one is just strange! I wish I could explain it better. It took me several hours to narrow down on the reproduction case because this only popped up in my ColdFusion application when I had several nested calls to a series of ColdFusion components.

Want to use code from this post? Check out the license.

Reader Comments

Post A Comment — I'd Love To Hear From You!

Post a Comment

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel
Managed hosting services provided by:
xByte Cloud Logo