We frequently run into issues with Broken Pipes causing our scripts to abort, and I was looking for a way to handle these. I had opened a topic on this same issue a few months ago but never got a response, so I’m assuming there isn’t a way, so I would just like to throw out a few ideas.
To clarify on the subject of this topic; why we are encountering these errors is a matter I am still looking into, but it’s not what I’m looking to discuss here. What has been driving me nuts is that there doesn’t appear to be a way to handle these errors. As far as I can tell if this error gets thrown, the script just aborts, and there isn’t anything I can do about it. Try/Catches don’t work. There doesn’t appear to be any settings to disable it. Complete fubar.
To be clear, I understand why you would want the option to abort if the server is no longer able to send output anymore, but it really should be an option, something that I, the developer, can disable if I deem it more important to ensure the script completes, rather than just killing the script altogether.
So here are my thoughts on this
-
Supply a flag that can be set in the script for enabling/disabling suppression of these errors. A builtin function, cfsetting suppressbrokenpipe=“boolean”, etc.
-
Maintain a separate flag while the script is executing indicating if the pipe has been broken. If so and we attempt to send output back to the requester, it will check the flag mentioned above in no 1. If suppressbrokenpipe is currently disabled, the output is just dumped, no errors are thrown.
-
Profit.