Skip to content

Fix CORS proxy crash on PHP 8.5+ due to curl_close() deprecation notice#3311

Closed
ashfame wants to merge 1 commit intotrunkfrom
fix/cors-proxy-php85-curl-close-deprecation
Closed

Fix CORS proxy crash on PHP 8.5+ due to curl_close() deprecation notice#3311
ashfame wants to merge 1 commit intotrunkfrom
fix/cors-proxy-php85-curl-close-deprecation

Conversation

@ashfame
Copy link
Copy Markdown
Member

@ashfame ashfame commented Feb 26, 2026

Motivation for the change, related issues

PHP 8.5 deprecated curl_close(), and the deprecation notice was being printed into the chunked HTTP response body, corrupting chunk framing and causing Node's HTTP parser to fail with "Invalid character in chunk size". Suppress the notice with @ to support all PHP versions.

CORS proxy is launched by php -S 127.0.0.1:5263 so uses native PHP on the machine. Mine is 8.5.3

Implementation details

Testing Instructions (or ideally a Blueprint)

PHP 8.5 deprecated curl_close(), and the deprecation notice was being
printed into the chunked HTTP response body, corrupting chunk framing
and causing Node's HTTP parser to fail with "Invalid character in chunk
size". Suppress the notice with @ to support all PHP versions.

Made-with: Cursor
@ashfame ashfame self-assigned this Feb 26, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 21:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents chunked HTTP response corruption/crashes when PHP emits a deprecation notice during request teardown in the CORS proxy.

Changes:

  • Suppresses the PHP 8.5+ deprecation notice emitted by curl_close() to avoid corrupting chunked transfer encoding output.
  • Updates inline comments to explain the rationale and failure mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +277 to +279
// Suppressed: curl_close() emits a deprecation notice in PHP 8.5+
// that corrupts chunked responses when display_errors is on.
@curl_close($ch);
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the error-suppression operator @ will silence all errors from this call (not just E_DEPRECATED), which can make real problems harder to diagnose. A more targeted approach is to temporarily suppress only deprecations (e.g., adjust error_reporting to exclude E_DEPRECATED around this call, then restore it), or disable display_errors for the streaming/chunked response path and rely on logging instead.

Suggested change
// Suppressed: curl_close() emits a deprecation notice in PHP 8.5+
// that corrupts chunked responses when display_errors is on.
@curl_close($ch);
// Suppress only deprecation notices from curl_close(), which emits a deprecation
// notice in PHP 8.5+ that corrupts chunked responses when display_errors is on.
$previousErrorReporting = error_reporting();
error_reporting($previousErrorReporting & ~E_DEPRECATED);
curl_close($ch);
error_reporting($previousErrorReporting);

Copilot uses AI. Check for mistakes.
@ashfame ashfame requested review from a team, fellyph and zaerl and removed request for a team and fellyph February 26, 2026 21:53
@ashfame
Copy link
Copy Markdown
Member Author

ashfame commented Mar 19, 2026

Closing since this has been addressed in #3391

@ashfame ashfame closed this Mar 19, 2026
@ashfame ashfame deleted the fix/cors-proxy-php85-curl-close-deprecation branch March 23, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants