Link to home
Start Free TrialLog in
Avatar of pmascari
pmascariFlag for United States of America

asked on

ColdFusion CFThread Failed to Set Header?

I'm getting a weird error from CFThread.  I have it wrapped around a function that runs perfectly when outside CFThread.  But, it takes about 20 seconds to complete so I shoot it off to CFThread then CFLocation the user to a new page and alert them when it's done.  

It's also wrapped in CFTRY to email me should there be a problem.

I'm getting emails where the CFCATCH.Message is:

"CFThread failed to set header to response as request had already completed"

I can't find any reference to an error like this on Google.  I'm assuming it's not liking the fact that I'm using CFLocation directly after invoking the Thread.  So, for the hell of it, I tried using a META REFRESH to redirect the user instead.  Same error result.

Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of mcnute
mcnute
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pmascari

ASKER

Hmmm...to my knowledge I'm not setting any headers.  I'm invoking a function in a CFThread so that it will run separate.  It builds a PDF and saves it to the server.  Instead of waiting for this the user is sent to a new page.

<cfset admsID = replace(createUUID(),"-","","all")>
<cfthread action="run" name="runADMS#admsID#" admsID="#admsID#" formstruct="#form#">
<cftry> 
<cfobject component="cfc.AutoDealerBrandMarketShare" name="adms">
<cfset rptPDF = adms.buildReport(dealer=formstruct.chosenDealer,mkt=formstruct.DMACode,make=formstruct.Make,rptID=admsID)>
<cfcatch type="any">
<cfmail to="pmascari@mysite.com" from="techsupport@mysite.com" subject="ADMS Error">
Error occurred running a Polk Auto Dealer Market Share report.
#cfcatch.Message#
#cfcatch.detail#
</cfmail>
</cfcatch>
</cftry>
</cfthread> 
<cflocation url="http://www.usercanwaithere.com">

Open in new window

Avatar of _agx_
> Hmmm...to my knowledge I'm not setting any headers

Well that's what cflocation does, it redirects by setting a header. Seeing as you're setting it outside the thread, I'm not sure why it's complaining .. From what I understand that shouldn't happen - only if you were trying to use it inside the thread.

Edit:  Hm.. maybe it's not the cflocation causing the problem. (Haven't been able to test it yet).  What's the code for buildReport(...) ? Maybe that method is generating some headers, and that's what's causing the error ? What code creates the pdf?
Any updates on the code inside buildReport(...)?
Sorry for the delay.  Several projects going at the same time....

Unfortunately, I have little to report.  The BuildReport() function is calling several other scripts that are all saving HTML in CFDocument variables and then assembling them all using CFPDF (building a report).  If saves the file to the local drive for the user to "pick up" later.

That process, outside the CFTHREAD, is working just fine.  It can take 20-30 seconds to compile which is why I'd like to send it to a Thread.

I'd also like to add that this process is working just fine IN THE THREAD in our development environment.  It's only when I place it on our live servers (CF10, Win 2008 R2, IIS 7.5) that I get this weird error.

I scoured the logs again for an indication.  Nothing....
I found it.  Sifting through the many scripts this function calls I found a CFHEADER tag sitting atop one of the CFDocument tags.  Not sure why our Development environment didn't kick this out?  Anyway, that was the issue.

*sigh*
I unknowingly had a CFHeader tucked in there.
Makes sense, that's what I mentioned in the subsequent (edit).  Glad you (finally) found the problem :)