Add error handling for failed child processes
Problem
Currently, when a child process fails during execution (e.g., throws an exception or exits abnormally), the parent process receives an empty string as the result. This makes it difficult to detect and debug failed child processes, as no error or indication is returned.
For example, when using example code from readme
$results = Fork::new()
->run(
fn () => (new Api)->fetchData(userId: 1),
fn () => (new Api)->fetchData(userId: 2),
fn () => (new Api)->fetchData(userId: 3),
);
If one of the fetch requests fails, the result array will be populated with empty strings, silently ignoring the failure.
Solution
This pull request adds basic error detection for failed child processes and ensures that any such failure results in an exception or at least a detectable error on the parent side. This improves reliability and makes debugging easier.
@freekmurze can you merge this?
tks @chaker2710
Your fork helped mt to find the empty string problem. Hope this get merged
Dear contributor,
because this pull request seems to be inactive for quite some time now, I've automatically closed it. If you feel this pull request deserves some attention from my human colleagues feel free to reopen it.