-
-
Notifications
You must be signed in to change notification settings - Fork 463
Description
Expected behaviour
All warnings are sent to sentry.
Actual behaviour
Only the first warning is sent to sentry, afterwards the sentry error handler gets unregistered.
Reproduction
First, the code has to be run on a webserver, otherwise the offending piece of code is never called.
I've set up a repo with the minimal requirements for reproducing this problem.
https://github.com/SunflowerFuchs/sentry-error
Offending piece of code
The actual unsetting of the error handler happens outside of sentry itself, in guzzlehttp/psr7. I will open an issue with them too, but I feel like there should at least be some tests here that should prevent issues like this in the future.
When sentrys errorhandler runs, at some point it tries getting the size of the request body.
sentry-php/src/Integration/RequestIntegration.php
Lines 181 to 185 in 7acdcdd
| if ( | |
| 'none' === $maxRequestBodySize || | |
| ('small' === $maxRequestBodySize && $requestBody->getSize() > self::REQUEST_BODY_SMALL_MAX_CONTENT_LENGTH) || | |
| ('medium' === $maxRequestBodySize && $requestBody->getSize() > self::REQUEST_BODY_MEDIUM_MAX_CONTENT_LENGTH) | |
| ) { |
At which point guzzlehttp/psr7 takes over, and at some point tries setting, and afterwards unsetting, an errorhandler.
https://github.com/guzzle/psr7/blob/4ae8647dd962ac404d578fd42e00ffc81cb00d75/src/functions.php#L311-L321
But since this piece of code is already being run within an errorhandler, restoring the previous errorhandler destroys the current errorhandler from sentry.
It's possible that this is a WONTFIX since the main problem is possibly outside of sentry, but I'm submitting here mainly so tests can be improved, and in case anyone else possibly comes across this problem.