Handling java.io.IOException: Broken pipe

Please read entire post before commenting.

So Broken Pipes have always been a somewhat intermittent issue. For the most part it’s never caused us too much trouble, but earlier today I had a long running script, that after about 5-10 minutes would keep throwing a Broken Pipe exception on a cfflush tag.

Because this seemed to occur regularly, I decided to use this as an opportunity to try and find a way to handle these better. So I tried writing a really simple custom tag that was essentially just a wrapper for cfflush. The idea was pretty simple. Wrap cfflush in a try-catch. If an error is thrown, I would check to see if a certain variable was set in the request struct which would determine if the error actually needed to be thrown, or if we could just ignore it.

<cfif NOT isdefined("thistag.ExecutionMode")>
	<cfoutput>Error - Must be called as a customtag.</cfoutput>
	<cfabort>
</cfif>

<cfif thisTag.hasEndTag>
	<cfabort>
</cfif>


<cftry>
	<cfflush>
<cfcatch>
	<cfif !(structKeyExists(Request, "SuppressBrokenPipe") AND Request.SuppressBrokenPipe)>
		<cfrethrow>
	</cfif>
</cfcatch>
</cftry>

However, this didn’t work. Then just as a sanity check, I removed the code in the catch tag, so that all cfflush errors would be ignore, but again, the catch didn’t work at all. The Broken Pipe exceptions are ignoring the try-catch all together.

So my first question is:
WTF?!?!? Why is my try-catch being ignored?

2nd, is there a way to suppress these so that we can still let the script run? I was originally hoping there would be a cfsetting or something like that where this could be controlled, but I’ve yet to find anything.

1 Like