Migrating cfml with flush to the user


we are migrating a legacy cfml that has some long term loops that do cfflush to inform the user the progress of the task.

This approach seems to not work with Coldbox, what is the best way to do it with it?


Hola mi amigo!

Unfortunately the issue is that cfflush is not supported within components because of some internal CF engine craziness with the output buffer. I requested this a long time ago and it has never happened. So In conclusion, I have never found a way to do this from within an event handler or view since they ultimately execute within a CFM page.

@bdw429s any ideas on this?

It really has nothing to do with CFC output buffers and everything to do with the fact that the ColdBox framework renders all views inside of a <cfsavecontent> so it can capture the output, wrap them in the layout, and then control when and how the output is sent to the client.

So if you have


and you call it like so

<cfsavecontent variable="local.viewOutput">
  <cfinclude template="myView.cfm">
<!--- later on in the request after wrapping in the layout,
   firing postRender interceptors, caching results etc, etc... --->

Then the cfflushes will basically do nothing since they are contained within the cfsavecontent.

There is not a good way to accomplish this with a framework that handles encapsulated rendering. What I’ve done is rework the page to use ajax polling or a websocket to send status information via an async thread.

Ok, we will try to change the logic and use ajax pulling to show the progress of the task to the user.

¡Muchas gracias amigos! Saludos desde Málaga :slight_smile: