Fix CORS proxy crash on PHP 8.5+ due to curl_close() deprecation notice#3311
Fix CORS proxy crash on PHP 8.5+ due to curl_close() deprecation notice#3311
Conversation
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
There was a problem hiding this comment.
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.
| // Suppressed: curl_close() emits a deprecation notice in PHP 8.5+ | ||
| // that corrupts chunked responses when display_errors is on. | ||
| @curl_close($ch); |
There was a problem hiding this comment.
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.
| // 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); |
|
Closing since this has been addressed in #3391 |
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:5263so uses native PHP on the machine. Mine is 8.5.3Implementation details
Testing Instructions (or ideally a Blueprint)