All work

 

cfflush not properly streaming output to browser

Description

The cfflush() function is not properly streaming content to the browser when used in a loop with delays between outputs. Content is only displayed when the entire response is complete rather than incrementally as expected.

Steps to Reproduce

  1. Create a CFM page with the following code:

<cfscript> loop times=10 { echo(now() & "<br>"); sleep(1000); cfflush(throwonerror=false); } </cfscript>
  1. Load the page in Chrome, Safari, or other modern browsers

  2. Observe that the timestamps don't appear incrementally every second as expected

Expected Behavior

Each timestamp should appear in the browser immediately after it's generated, with a new timestamp appearing each second.

Actual Behavior

No output is displayed until all 10 iterations are complete, at which point all timestamps appear at once.

Environment

  • Lucee Version: [Version number]

  • Application Server: Tomcat 9

  • Browsers tested: Chrome, Safari

  • OS: [Operating System]

Impact

This issue impacts any application that relies on real-time streaming of content to the browser, particularly:

  • Real-time log viewers

  • Progress indicators

  • Streaming responses from external APIs

  • AI response streaming

Additional Information

The issue appears to be related to buffering at either the Lucee or Tomcat level. The cfflush() function is not successfully forcing all buffered content to be sent to the client.

When examining the buffer size with:

rsp=getPageContext().getResponse(); dump(rsp.getBufferSize());

The output shows a buffer size of 8192 bytes. Content appears to only be flushed to the browser when this buffer is completely filled, despite explicit calls to cfflush(). This explains why small content outputs with cfflush() calls are not being displayed incrementally as expected.

Environment

None

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Created 15 April 2025 at 17:09
Updated 6 May 2025 at 13:23

Activity

dan.switzer@givainc.com 
6 May 2025 at 13:13

The cfflush issue.

We’re needing cfflush to immediately flush the output and without the HttpServletResponse.flushBuffer()in cfflush, the behavior in Lucee 6 is different than Lucee 5.

dan.switzer@givainc.com 
5 May 2025 at 19:27

I’m running into this issue in 6.2.1.122.

Is there an ETA on when this fix might be released?

Zac Spitzer 
17 April 2025 at 15:28
(edited)

6.2 is broken due to this failing

public void function test() localmode="true"{ var data=GetContextInfo(); systemOutput(data, true); assertEquals(false,data.flushed); }

why did we add if all GetContextInfo() does is the same?

Zac Spitzer 
17 April 2025 at 16:28

naming is an art form!

Zac Spitzer 
16 April 2025 at 20:33

there's good performance reasons why buffering is the default here, can we at make the old behavior an option, or make this buffer free option available via a Boolean argument

 

Michael Offner 
17 April 2025 at 15:54

when you do a flush; still having a buffer makes no sense, this is only used when we explicitly flush something

Michael Offner 
15 April 2025 at 17:23

Fixed by adding response.flushBuffer() call to the flush() and _flush() methods in CFMLWriterImpl. The original implementation was flushing the internal buffers but not the underlying servlet response buffer.

public void flush() throws IOException { flushBuffer(true); out.flush(); response.flushBuffer(); // Added this line }

Fix Availability:

  • Lucee 6.2:

  • Lucee 7.0: