Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error
If you are seeing net::ERR_INCOMPLETE_CHUNKED_ENCODING in your browser console, accompanied by truncated CSS or JavaScript files and hanging pages, the root cause is almost certainly a mismatch in how the server handles the HTTP 1.1 protocol's chunked transfer encoding. This specific scenario often presents itself as an isolated issue affecting only a single user or developer on an otherwise healthy infrastructure.
The error message indicates that the browser received a Transfer-Encoding: chunked header but failed to receive the complete set of chunks required to reconstruct the response body before the connection closed. In many cases, this manifests as a partial download where the final bytes are missing or corrupted.
A common diagnostic sign is that the issue persists across different browsers (like Firefox) and even when disabling extensions or using Incognito mode. While Firefox may not explicitly throw this console error, inspecting the network tab via Firebug will reveal the same truncated content. The fact that the problem affects only one user on an Apache 2.2.22 server suggests a local client-side configuration state rather than a systemic server outage affecting all clients.
The Root Cause: HTTP/1.1 Chunked Encoding Mismatch
The core of this issue lies in the interaction between the client's expectation of a full payload and the actual data stream provided by the server. When Apache is configured to send large responses, it often defaults to Transfer-Encoding: chunked. This allows the server to stream the response body in pieces rather than waiting to calculate the total content length upfront.
However, if the connection drops prematurely, or if the client disconnects before the final zero-length chunk is received, the browser interprets this as an incomplete transfer. In the specific instance described, the headers show Content-Encoding:gzip alongside Transfer-Encoding:chunked. This combination can sometimes trigger edge cases in older versions of Chrome or Firefox where the decompression logic struggles if the stream terminates unexpectedly.
The Workaround and Why It Fails
In some instances, forcing the server to speak HTTP/1.0 resolves the issue immediately. In Apache, this is achieved by adding SetEnv downgrade-1.0 to your .htaccess file. HTTP/1.0 does not support chunked encoding; instead, it relies on a definitive Content-Length header. By switching protocols, the server stops using chunked transfer and sends the full payload length upfront.
While this workaround eliminates the error, it is fundamentally flawed for modern web applications. Forcing HTTP/1.0 disables persistent connections (keep-alive), which significantly increases latency by requiring a new TCP handshake for every resource request. It also negates the efficiency of chunked encoding for streaming content. Relying on an obsolete protocol to mask a deeper configuration or connection stability issue is not a sustainable engineering decision.
Investigating Client-Side State
When troubleshooting isolated errors like this, consider that the server environment might be identical for everyone, but the client state varies. In the scenario where restoring Chrome settings temporarily resolves the problem, it points to a corrupted cache of HTTP expectations or a stuck socket buffer within the browser's networking layer. The error reappearing after 10â20 minutes suggests that as the browser accumulates more state or attempts to reuse connections, the mismatch becomes apparent again.
Recommended Resolution Strategy
The most robust solution is not to downgrade the protocol but to investigate why the chunked stream is being interrupted for your specific user. Check for:
- Proxy Intermediaries: Ensure there are no corporate proxies or firewalls between the client and server that might be terminating connections prematurely.
- Socket Timeouts: Review
mod_proxysettings if you are behind a load balancer, ensuring that timeouts align with your largest expected response sizes. - Browser Updates: Since this affects specific Chrome versions, ensure the latest patch is applied, as Google frequently updates its HTTP handling logic to address edge cases in chunked decoding.
If the issue persists strictly on one machine, clearing the browser cache and disabling hardware acceleration can often reset the networking stack's internal buffers, providing a clean slate for the connection negotiation.
