Skip to content

Proxy hangs 30 seconds on PHP responses with chunked Transfer-Encoding #731

@blar

Description

@blar

When using CodeKit as a reverse proxy in front of an Apache/PHP-FPM server, Safari hangs for ~30 seconds on every PHP response. Static HTML files load instantly.

Environment:

  • CodeKit (latest)
  • Apache 2.4 + PHP-FPM via proxy_fcgi
  • Safari 26.0 (macOS)

Root cause:

Apache's proxy_fcgi module sends PHP responses with Transfer-Encoding: chunked because the response size is unknown at header time. CodeKit receives the chunked response, decodes it, injects its reload script, and then forwards it to the browser with both Transfer-Encoding: Identity and Content-Length set simultaneously.

This combination causes Safari to wait ~30 seconds before rendering. Chrome is unaffected.

Verified with mitmproxy between Safari and CodeKit:

First response byte: 23:19:11.188
Response complete:   23:19:41.190  ← 30 second gap

CodeKit receives the response immediately but holds the connection open for 30 seconds before closing it.

Reproduction:

  1. Set up Apache + PHP-FPM as external server in CodeKit
  2. Create index.php with only echo "foo";
  3. Open via CodeKit preview URL in Safari
  4. Observe 30 second hang

Expected behavior: PHP responses should load as fast as HTML responses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions