-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding error handler changes symfony error handler #421
Comments
Not sure about this... @nicolas-grekas, could you help us out here? Does the Symfony error handler NOT support closures as handlers? |
I experienced the same issue on our Symfony apps. There is nothing special to do to reproduce: the issue is that when When running tests, this leads to a red warning that says This could be fixed by making Sentry not set its error handler when no DSN is defined. Do you think that's doable? Then there is this in Honestly, I don't get why Sentry would hook as an error handler: in the context of Symfony, we already have logs to report PHP warnings/etc. Can't this be removed? I might also try to find another way to get access to our error handler so that we can still configure it when another piece of code replaces it. |
See symfony/symfony#39944 for the issue related to For tests, it would be great if this bundle could provide a way to not instantiate |
Thanks a lot @nicolas-grekas for the fast PR on your side. As for not injecting our handler, it's doable and we already discussed it in #337, but we didn't find the time to do it; it's a big change for us and it's a lot less "plug & play" for our users, since it would require writing down an handler inside the Monolog config, so it doesn't seems solvable with Flex either. |
I propose to fix this at the recipe level, see symfony/recipes-contrib#1080 |
…erriden (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] Configure the ErrorHandler even when it is overriden | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Fixes the part of getsentry/sentry-symfony#421 that is about `DebugHandlersListener`. Commits ------- 31817b4 [HttpKernel] Configure the ErrorHandler even when it is overriden
Even with the handler being skipped, if no DSN is provided, the custom error handler still interferes with our Symfony configuration:
I thought, as a workaround, I could just use the Sentry PHP SDK and write a small Monolog-Handler to log to Sentry but as the SDK itself ( At first I thought that As much as I like Sentry, I don't understand why it needs to register its own error handler. Especially in the context of Symfony or other frameworks that support Monolog. Maybe I don't grasp all the features and what they need to be working but I would think that an simple Monolog handler that I could put into my monolog chain would be enough to send my errors to Sentry. |
Using a simpler approach with a Monolog handler is already what we would like to do (since it was already suggested by Nicolas and tracked in #337), but it's doable only here in the context of a Symfony app and not in the base SDK ( As for disabling the error handler, it's currently enabled by the |
This sounds a lot like the issue described in #421 (comment)
Indeed, but looking again at the code of version
Agree. It has always been this way I believe, and we missed the opportunity to change this in time for the release of version |
Yeah that seems the code from #204. This factory was used to remove them: https://github.com/getsentry/sentry-symfony/blob/3.5.x/src/DependencyInjection/IntegrationFilterFactory.php |
Hi @Jean85 and @ste93cry, It all seems to be very complicated and following your referenced pull requests or issues is like going down a rabbit hole, because they all lead to other PRs or issues (I stopped when I somehow reached the HttpPlug documentation and the different HTTP PSRs which, honestly, I don't want to bother with, but that's a whole other story). https://github.com/B-Galati/monolog-sentry-handler looked like a promising Monolog-based approach, but it doesn't support Sentry SDK 3 yet and is "only" a Monolog Handler without any integration (it has a documenation for a Symfony integration, though). I'm a little flooded with information and right now, as I need to accept the fact that I don't have any free time, I think I'll just wait this out and don't try to solve it on my own. There seem to be a lot of bright people on this, so I don't think I would be of any help anyway. |
Is there maybe a work-around for this? 🙂 |
Since you're likely using Monolog in a Symfony app, to workaround the issue you can activate the Monolog handler we provide and then configure the |
For reference, on the Drupal side of things, which also has its own error and exception handlers, I disable ExceptionListenerIntegration and ErrorListenerIntegration, but keep FatalErrorListenerIntegration (as catching fatals didn't seem to conflict) |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
🦚 |
Updating to My application is still on Symfony 4 with several components from the 5.x range. This gives several deprecation warnings on startup:
These warnings are caught before the error handling is fully set up, and they are stored in the
My work around it to disable the standard integrations and load all non-handling integrations myself: default_integrations: false
integrations:
# Defaults integrations except the error and exception handlers because we use Monolog for that.
- 'Sentry\Integration\RequestIntegration'
- 'Sentry\Integration\TransactionIntegration'
- 'Sentry\Integration\FrameContextifierIntegration'
- 'Sentry\Integration\EnvironmentIntegration' |
@jorrit did you check the bundle loading order? Maybe you can load the Sentry bundle later (after Monolog?) to fix this issue? |
When using older version of Sentry (v2) with Symfony (v5.2) the handler in
DebugHandlersListener::configure()
isin Sentry v3 the
ExceptionListenerIntegration
overrides exception handler inregisterOnceExceptionHandler()
via linetherefore the handler is now of type
Closure
, notarray
And the condition in Symfony's
DebugHandlersListener
is not satisfied$handler
is nownull
.That kind of significantly influences the rest of app behaviour.
TBH I don't know what is the proper solution to the problem. Is it intended? I wish to keep Symfony error handler as I hook into its events.
Setting
$handler
tonull
forcessymfony/debug
's ErrorHandler to be used instead and I don't want that, it does not useonKernelException()
listeners for example.(
)
The text was updated successfully, but these errors were encountered: