Broken Pipe when logging with defer()
Hey team, I'm pulling my hair out over this one a little bit.
I'm experimenting with the new Concurrency feature, specifically the defer() method.
I have a controller method I'm using to experiment with, which looks like this:
Route::get('/defer', function () {
Concurrency::defer([
function () {
sleep(5);
\Illuminate\Support\Facades\Log::info(now()->format('Y-m-d H:i:s'));
},
]);
return response(now()->format('Y-m-d H:i:s'));
});
What I expect to happen is that I receive the current timestamp in the response, and then 5 seconds later that new timestamp is logged to laravel.log.
Both of those things happen, but I also receive a lot of errors in laravel.log stating that my log couldn't be written to due to a Broken Pipe. This is despite the fact that my log was successfully written. See:
[2024-11-26 11:20:14] local.INFO: 2024-11-26 11:20:14
[2024-11-26 11:20:14] local.ERROR: Writing to the log file failed: Write of 56 bytes failed with errno=32 Broken pipe
The exception occurred while attempting to log: 2024-11-26 11:20:14 {"exception":"[object] (UnexpectedValueException(code: 0): Writing to the log file failed: Write of 56 bytes failed with errno=32 Broken pipe
The exception occurred while attempting to log: 2024-11-26 11:20:14 at /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:186)
And then this is followed by a big nested stack trace where it logs out an exception, but then another exception is thrown and logged claiming that the previous one couldn't be written.
Anyone have any idea what might be causing this weird behaviour?
Please or to participate in this conversation.