Skip to content
Jul 18 06

Unexpected cftimer Behavior

by Mike

This is a fun one, After beating my head against the wall for a bit, I discovered an interesting behavior when using cftimer and cfheader (or cflocation) together. Follow along….

First I saw this error….


Error Occurred While Processing Request

Failed to add HTML header.


ColdFusion was unable to add the header you specified to the output stream. This is probably because you have already used a CFFLUSH tag in your template,or buffered output is turned off

At this point, I thought to myself, “Thank you coldfusion, I must have a CFFLUSH tag somewhere in my code, this should be easy to find”. But, unfortunately this wasn’t the case… No CFFLUSH tags anywhere in the code… hmmm.

Finally, I figured it out. As far as I can tell, CFTIMER actually sends the buffer to the client when type is set to “inline” or “comment”. Take a look for yourself. With debugging/timer info enabled the following code executes without any problems.


	



Now try changing type to “comment” and execute the code and you will see an exception. Here’s a sample…


	



In my case, the error occurred only in a dev environment, when I was adding a cfheader tag. The timer tags had been in there for a while, so it was extremely hard to figure out why I was getting this error. An even more confusing situation would be the following code


	



In this case, the code would appear to execute without any problems, but would simply fail to do the redirect, think about how much time you could waste on that one if a cftimer tag is buried in your code.

Lesson of the day
Take note just in case you come across this. Additionally this should probably be added to liveDocs for cfheader and cflocation

Jul 16 06

First Post

by Mike

I’m not much of a blogger, but I saw that Ray released version 5.1 of BlogCFC, so I figured that now was as good of a time as any to start. Plus I have a new tool that I plan to release in the next few days. I’m pretty excited about it and hoping that everyone else will find it as useful as I do.