[GH-ISSUE #1989] StreamHandler choking on php://stderr #855

Closed
opened 2026-03-04 03:01:33 +03:00 by kerem · 2 comments
Owner

Originally created by @jdwx on GitHub (Sep 17, 2025).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1989

Monolog version 1|2|3? 3.9.0

Recently we've started getting this

File: .../vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
Line: 186

Message: Writing to the log file failed: Write of 8748 bytes failed with errno=32 Broken pipe

From this handler:

$format = new LineFormatter( allowInlineLineBreaks: true );
$log = new StreamHandler( 'php://stderr', Level::Info );
$log->setFormatter( $format );

I'm a little baffled as to how that could happen. The stderr output is not closed; I have this information because our emergency backup exception handler is logging it there after this happens.

The environment is php-fpm.

Since I don't understand how this could happen, I'm not sure how to try to debug this. I'm not sure if this is a Monolog bug, or how it could be, but since stderr remains available in the process, just not to Monolog, I would really appreciate any possible insight into what might be going on.

This started happening rather suddenly about a week ago without any changes to the environment, and, worst of all, it is intermittent.

Originally created by @jdwx on GitHub (Sep 17, 2025). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1989 Monolog version 1|2|3? 3.9.0 Recently we've started getting this ```php File: .../vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php Line: 186 Message: Writing to the log file failed: Write of 8748 bytes failed with errno=32 Broken pipe ``` From this handler: ```php $format = new LineFormatter( allowInlineLineBreaks: true ); $log = new StreamHandler( 'php://stderr', Level::Info ); $log->setFormatter( $format ); ``` I'm a little baffled as to how that could happen. The stderr output is not closed; I have this information because our emergency backup exception handler is logging it there after this happens. The environment is php-fpm. Since I don't understand how this could happen, I'm not sure how to try to debug this. I'm not sure if this is a Monolog bug, or how it could be, but since stderr remains available in the process, just not to Monolog, I would really appreciate any possible insight into what might be going on. This started happening rather suddenly about a week ago without any changes to the environment, and, worst of all, it is intermittent.
kerem 2026-03-04 03:01:33 +03:00
  • closed this issue
  • added the
    Bug
    label
Author
Owner

@IanAtOcucom commented on GitHub (Oct 23, 2025):

I am also seeing this error from time to time using apache mod_fcgid and PHP 8.3.

It seems to be related to stale PHP Sessions[?]

<!-- gh-comment-id:3438607878 --> @IanAtOcucom commented on GitHub (Oct 23, 2025): I am also seeing this error from time to time using apache mod_fcgid and PHP 8.3. It seems to be related to stale PHP Sessions[?]
Author
Owner

@Seldaek commented on GitHub (Oct 23, 2025):

See #1860 and #1634 - this happens sometimes and there are many theories as to why but nobody has come up with anything conclusive yet sorry

<!-- gh-comment-id:3438866849 --> @Seldaek commented on GitHub (Oct 23, 2025): See #1860 and #1634 - this happens *sometimes* and there are many theories as to why but nobody has come up with anything conclusive yet sorry
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#855
No description provided.