How NOT to code a CFLOOP

Posted on April 15, 2008

I’ve been chasing down a CFLOOP timeout error in one of our apps that escaped our rewrite project. After searching through code for 3 weeks, var scoping a bunch of CFCs and wading through a ton of business logic I think I found the culprit.

Of course, it would have to have been in the last file in my list.

Primary Suspect

<cfloop from="1" to="99999" index="x" >

  <cfset a = a + someQueryValue />
  <cfset b = b + anotherQueryValue />

  <cfif ( a gt c ) or ( b gte yetAnotherQueryValue )>

    <cfset x = 99999 />
    <cfbreak />

  </cfif>

</cfloop>

Book ‘em Danno!

About the Author
Adrian J. Moreno

Adrian is an enterprise solution architect and full stack developer. Which stack depends on which system is on fire at the time. More information