Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel] Add "handle-all-throwables option to handle thrownError in addition toException`#47467
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
76a8b23 to1a26822CompareNyholm commentedSep 2, 2022
Thank you. What is the plan for 7.0? Just to change the default behaviour without warning? |
catch56 commentedSep 3, 2022
Just to say for Drupal this was an easy change for us - we had to add the parameter to our container definition, and update one test (it tests what happens with an specific uncaught exception, that is now caught), nothing else. I think this also means that if the behaviour changes without warning in Symfony 7, this would also be OK - we'd still have to update one test. |
nicolas-grekas commentedSep 3, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The plan on my side should be to keep things as is, aka no change of the default. It's fine to let Error throw out on short-living processes,and in tests. The deprecation + behavior change would require ppl to 1. opt-in for the new default and 2. update their test cases. Both worry me, like in "not worth it, cost is too high compared to the benefits". (+ I'm not sure it's good defaults to swallow Error, in tests especially). |
nicolas-grekas commentedSep 3, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Here is another thought I had when looking at your use case@Nyholm: should it be possible to handle exceptions without cooperation from configuration? If that'd be desirable, there could be two ways to do it:
Did you consider those options? Would they fit better for you? (as in: no change in config to support both long and short-living runtimes.) |
nicolas-grekas commentedSep 3, 2022
Two more options: 3. a setter/wither, 4. a decorator. |
chalasr commentedSep 3, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
👍 for reverting the deprecation as short-lived processes is still the main use case. No strong opinion about the alternative, the config option is fine to me. |
1a26822 to00999b2CompareNyholm commentedSep 28, 2022
I think there are two questions here.
I think (Please confirm) what we are happy to do 2. But@nicolas-grekas is hesitant about 1. Except for the potential cost of migrations, is there any other reason we should not change the defaults? |
f480d00 tod74ea89CompareHttpKernel to handle thrownError in addition toExceptionHttpKernel to handle thrownError in addition toException_handle_all_throwables to allowHttpKernel to handle thrownError in addition toExceptionnicolas-grekas commentedSep 29, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks for having a look. You're right about 1. and 2. I know that we already tried doing this change and that this broke some apps that did expect to catch While considering your questions, I figured out another approach that might be a better fit. This means ppl that use modern stacks (aka Runtime) will have the new behavior enabled by default. I think this is safe and legit because Runtime is expected to work on both on long-running and short-living engines. And ppl that still use the old index.php won't see any difference. If we want to enable this behavior by default, we can still consider deprecatingnot setting the new attribute in >= 7.1, and handle all throwables by default in 8.0. But meanwhile, we provide a smooth upgrade. Makes sense? |
| publicfunctiontestArgumentValueResolverDisabled() | ||
| { | ||
| $client =$this->createClient(['test_case' =>'Uid','root_config' =>'config_disabled.yml']); | ||
| $client->catchExceptions(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We don't needExceptionSubscriber because we can do this instead.
derrabus commentedSep 29, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'd throw in another option: Change the interface of the On Symfony 7, this could look like this: interface HttpKernelInterface{publicconstMAIN_REQUEST =1;publicconstSUB_REQUEST =2;publicfunctionhandle(Request$request,int$type =self::MAIN_REQUEST,CatchThrowables$catch = CatchThrowables::AllThrowables ):Response;}enum CatchThrowables{case AllThrowables;case ExceptionsOnly;// like $catch === true on 6.1case None;// like $catch === false on 6.1} We should be able to create a smooth upgrade path for that. |
nicolas-grekas commentedSep 29, 2022
I considered this@derrabus but I don't see any smooth upgrade path to make it happen. Do you have one in mind? |
derrabus commentedSep 29, 2022
For 6.2, we can add the enum already comment out the interface HttpKernelInterface{publicconstMAIN_REQUEST =1;publicconstSUB_REQUEST =2;publicfunctionhandle(Request$request,int$type =self::MAIN_REQUEST,/* CatchThrowables $catch = CatchThrowables::AllThrowables, */ ):Response;} Our |
nicolas-grekas commentedSep 29, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Actually, I just realized that There is another thing that the attribute provides and that highlights the difference: the attribute I'm proposing allows deciding if errors should be handled only for the main request or also for subrequests. That's not something that In the current patch, only the main request will handle errors. I think that's appropriate. You mention that adding an attribute is not really well discoverable. That's true, but the vast majority of devs won't have to discover it because this is outside of the scope of coding in Symfony. Only ppl that work at the runtime/bootstrap level might be interested in using that attribute. Our Runtime component will enable the flag by default and done. IF we really want to make this more discoverable, I suggested an approach that could work for v7.1+/8.0. By the time, we might have more clues on the topic and decide if we need something else. |
nicolas-grekas commentedOct 11, 2022
Any other input here? I don't want us to release the deprecation if that's not what we want. |
nicolas-grekas commentedOct 17, 2022
About this proposal, I'm not convinced it makes sense: exposing the behavior as public API doesn't look desired to me as the difference is too subtle. Better keep this as an implementation detail IMHO. |
fabpot left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I like it, especially with the related PR on runtime.
nicolas-grekas commentedOct 18, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
After talking with ppl in the core-team, I updated the implementation:
People that use a long-running runtime SHOULD enable the new option (that's doc to write on php-runtime@Nyholm), and ppl on short-lived runtime MIGHT enable it without any nasty side-effect, unless they rely on the previous behavior. This means we SHOULD enable the option by default in the recipe for 6.2. As ppl migrate to 6.2+, they will sync their recipes and the majority should get the option turned on by 7.1. This should make it cheap to trigger a deprecationif we want everybody to use it by then. |
derrabus commentedOct 18, 2022
So basically, we revert the deprecation and change the name of the config flag? That sounds good to me. Thanks. 👍🏻 |
nicolas-grekas commentedOct 18, 2022
Basically yes. We also remove |
Nyholm left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you!
…`HttpKernel` to handle thrown `Error` in addition to `Exception`
nicolas-grekas commentedOct 18, 2022
Thank you all for the review! |
_handle_all_throwables to allowHttpKernel to handle thrownError in addition toException option toHttpKernel to handle thrownError in addition toException` option toHttpKernel to handle thrownError in addition toException` option to handle thrownError in addition toException`This PR was merged into the 2.x-dev branch.Discussion----------[Tests] Remove unnecessary 6.2 configsincesymfony/symfony#47467Commits-------005757f [Tests] Remove unnecessary 6.2 config
This PR was squashed before being merged into the 0.x-dev branch.Discussion----------[Tests] Remove unnecessary 6.2 configsincesymfony/symfony#47467Commits-------a279ded [Tests] Remove unnecessary 6.2 config
Uh oh!
There was an error while loading.Please reload this page.
I understand the motivation behind#45997 but I don't think the deprecation is worth the migration cost onall users of Symfony.
The burden of enabling this setting should only be on use cases where getting a response back is needed.
The previous behavior was just fine in common situations.
/cc@catch56 for Drupal FYI
/cc@Nyholm also