Skip to content

#299: Test that a throwing fnmatch callback reaches the awaiter - #300

Merged
EdmondDantes merged 1 commit into
mainfrom
299-curl-callback-exception-handoff
Sep 10, 2026
Merged

EdmondDantes merged 1 commit into
mainfrom
299-curl-callback-exception-handoff

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

Closes #299. Carries the test and the CHANGELOG entry for true-async/php-src#37.

tests/curl/072-fnmatch_exception.phpt drives a wildcard FTP transfer against the server from ext/ftp/tests/server.inc with a CURLOPT_FNMATCH_FUNCTION callback that throws on its first call. Without the php-src change the awaiter catches Async\AsyncCancellation: Graceful shutdown and the throw surfaces afterwards as an uncaught fatal error; with it the awaiter catches the RuntimeException.

The callback throws once and answers CURL_FNMATCHFUNC_NOMATCH afterwards, so the assertion names one exception: libcurl calls the callback once per listed entry regardless of what the previous call did, and the exceptions chain through previous. The synchronous path behaves the same way, which is upstream php-src behaviour and untouched here.

The host-key half of #299 has no test. This machine's libcurl carries neither sftp nor scp in curl_version()['protocols'], so CURLOPT_SSH_HOSTKEYFUNCTION cannot be reached.

Merge order: the CI job clones php-src true-async-stable, so true-async/php-src#37 has to reach that branch first. Until then this test fails on CI, which is the same failure it was written to prove.

Testing

  • ext/curl/tests + ext/async/tests + ext/async/fuzzy-tests/_generated, ZTS debug, libcurl 8.12.1: 2116 passed, 0 failed.
  • The new test on its own: red before the php-src change, green after.

The exception left in EG(exception) escaped outside the coroutine as an
uncaught fatal error while the awaiter was woken with a cancellation. The
test drives a wildcard FTP transfer against the server from
ext/ftp/tests/server.inc with a callback that throws once.
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@EdmondDantes
EdmondDantes merged commit 515587e into main Sep 10, 2026
9 of 16 checks passed
@EdmondDantes
EdmondDantes deleted the 299-curl-callback-exception-handoff branch September 10, 2026 17:20
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.

A throwing fnmatch or SSH host-key callback escapes the coroutine as an uncaught error

1 participant