-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Added ErrorDetailsStamp #32904
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
[Messenger] Added ErrorDetailsStamp #32904
Conversation
@@ -75,6 +75,10 @@ public function testItSendsAndReceivesMessages() | |||
$this->assertEmpty(iterator_to_array($receiver->get())); | |||
} | |||
|
|||
/** | |||
* @group legacy | |||
* ^ for now, deprecation errors are thrown during serialization. |
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.
how can people prevent the deprecation from happening?
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.
Currently, the deprecation is being triggered by a fallback. This fallback is used in case people have messages in the queue while updating their codebase to a version that includes this PR.
Newer messages that are retried after this PR is downloaded will no longer trigger this deprecation.
Also I think the error details stamp should be added by each retry (not just when failing at the end). When we have the retry errors, the failed command should be able to list all the errors (not just diplay the last one). With this feature added, the PR would actually give a nice DX improvement. Currently it's just a small refactoring without much gain for users. |
Hi @Tobion, thank you for your review. The idea for this PR is that it paves the way for a few follow-up PRs that include more changes and DX improvement (like a limit on the amount of error stamps). In order to keep this PR as small as possible (to make reviewing easier), @weaverryan and I decided to break the total work up in several separate PRs. I'll look over your suggestions and rebase and make changes this week. |
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.
Sorry for the MASSIVE delay on reviewing Timo. It's really nice work - I've left some comments.
But, to make sure that we're fully thinking of the current status versus the improved status if this PR is merged, can you make the direct case for why we should merge this? What I mean is, I think (once we fully got #32341 done) that this PR makes getting the error information off of the Envelope easier because it's not attached to the RedeliveryStamp. So instead of looking through all the RedeliveryStamps to find the most recent one with exception information, you can now look directly at the ErrorDetailsStamp
: any of these will always contain the error details. In other words, it's kind of a cleanup / convenience. But I think (and this where I need your help), it doesn't solve any huge thing. If I'm right, with some many changes originally in this area, that wasn't obvious to me until now.
Thanks :)
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/FailedMessagesShowCommand.php
Outdated
Show resolved
Hide resolved
This is a really nice improvement! Any way to push this forward? It would be helpful to port this into 5.x as a BC layer, and be able to start relying on it. |
Hi @weaverryan & @Jean85, thanks for the review and kind words. I hope I have time soon to rebase and do some more work on this. @weaverryan The main reason for this PR is to decouple the retries (how many times have we done this and when should we stop trying?) from the errors (what went wrong?). We saw some issues where the errors caused problems with the envelope getting too large (especially when the retry number was high). Decoupling this can help us in the future by for example limiting the maximum amount of error stamps (by removing the oldest) without losing information about retries. Right now, this PR also includes ignoring duplicated errors (in case the same error as the last one occurs), since it wouldn't add any new information. Perhaps it would also be easier to hook into the flow of things when these stamps are separated. |
@TimoBakx Do you think you will have to time to work on this PR in the near future? |
@fabpot Yes, I should have time in the weekends of weeks 39, 40 and 41. |
@Tobion, @weaverryan I have rebased the code with the recent master branch and included your suggestions. Edit: AppVeyor fails due to an unrelated test. |
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 left minor comments that we do need to handle, but this looks great!
As Timo said, it's just a nice, decoupling of the "retry" information from the "failure information". I love it!
src/Symfony/Component/Messenger/Event/AbstractWorkerMessageEvent.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Event/WorkerMessageFailedEvent.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Outdated
Show resolved
Hide resolved
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.
This is ready!
Thank you @TimoBakx. |
…from the Messenger component as event subscriber (Jeroen Noten) This PR was merged into the 5.2-dev branch. Discussion ---------- [FrameworkBundle] Register AddErrorDetailsStampListener from the Messenger component as event subscriber | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT This is a fix for a bug in version 5.2-BETA3. In #32904, adding the error details to a failed message in the Messenger component was moved to a separate listener. However, this listener is not registered in the FrameworkBundle, resulting in no error details stored at all (when using the Symfony skeleton). This PR adds that missing registration. Commits ------- deda2ac [FrameworkBundle] Register AddErrorDetailsStampListener from the Messenger component as event subscriber
@@ -122,6 +154,23 @@ protected function getReceiver(): ReceiverInterface | |||
|
|||
protected function getLastRedeliveryStampWithException(Envelope $envelope): ?RedeliveryStamp | |||
{ | |||
if (null === \func_get_args()[1]) { |
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.
this method only has one argument. isn't that accessing a non-existing argument which will result in a php warning?
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.
As discussed on Slack, I'll add a new PR in which I replace this check (that causes a warning if \func_get_args()[1]
is not set) with a check on \func_num_args
.
@@ -27,9 +27,33 @@ final class RedeliveryStamp implements StampInterface | |||
public function __construct(int $retryCount, string $exceptionMessage = null, FlattenException $flattenException = null, \DateTimeInterface $redeliveredAt = null) |
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.
the arguments itself have not been deprecated and the order needs to be changed ($redeliveredAt before exceptionMessage and flattenException )
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.
As discussed on Slack, I'll create a new PR to:
- Remove the $exceptionMessage parameter
- Remove the $flattenException parameter
- Add checks on amount of parameters given and type-checks for those parameters to trigger the deprecation warnings.
Hi @TimoBakx and thank you for this improvement. How are we supposed to deal with these deprecations when an exception is thrown while handling a message ?
I'm using amqp transport. Edit : I use Doctrine Transport for failure. I suspect Doctrine is trying to Normalize the whole envelope of the message. The Normalization process is calling every methods of the objects (Stamps here). Maybe this issue can be ignored. Thanks |
Hi @AdrienBr, thanks for reaching out. These deprecations warnings can be thrown by internal code and are caused by a backwards compatibility for Symfony 5.x. We kept the older method so that older code that was still relying to the older stamps would still work correctly. In Symfony 6.0, the older stamps should not be used in this way anymore and the deprecation warning will disappear. So for now, if you get these deprecation warnings in your project, you can safely ignore them, as long as they're not caused by your own code. |
#SymfonyHackday
This PR is part of the work started in #32341. That PR has a workaround for showing exceptions added to a previous retry. This PR stores error messages in a separate stamp, so they're more easily accessed.
I also added the exceptionClass as a separate string (independant of FlattenException), so that information is always available, even if the trace is not (due to FlattenException not being available).
Duplicated exceptions (compared to the last one) are not stored separately.
Questions:
HandlerFailedException
, should we add a stamp per wrappedThrowable
? There can be multiple errors wrapped by a singleHandlerFailedException
.Todo:
BC Breaks:
When this PR is merged, RedeliveryStamps will no longer be populated with exception data. Any implementations that use
RedeliveryStamp::getExceptionMessage()
orRedeliveryStamp::getFlattenedException()
will receive an empty string ornull
respectively for stamps added after this update. They should rely onErrorDetailsStamp
instead.New stuff:
ErrorDetailsStamp
.AddErrorDetailsStampListener
.AbstractWorkerMessageEvent::addStamps
.