Handler receives the envelope instead of the message it was registered for
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
Piste de recherche
Read Worker.php, ConsumeFinalHandler.php, and the guide at docs/guide/en/messages-and-handlers.md:108; trace how IdEnvelope, DelayEnvelope, and FailureEnvelope move through the consume pipeline. First resolve the contract choice raised in the issue, especially alongside the #338 Worker and pipeline rework. Done means handlers receive the intended message or envelope contract consistently, with the guide and behavior agreeing.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Worker::process() passes the message into the consume pipeline exactly as it arrived, and ConsumeFinalHandler hands that to the handler. Nothing unwraps an envelope on the way, so a handler written the way the guide writes it breaks as soon as the message is wrapped.
The documented handler (docs/guide/en/messages-and-handlers.md:108):
public function handle(MessageInterface $message): void
{
assert($message instanceof SendEmailMessage);
$this->mailer->send($message->to, $message->subject, $message->body);
}
Called with an adapter-assigned id, which is the normal asynchronous path:
$worker->process(new IdEnvelope($message, 'id-42'), 'test');
With zend.assertions=1:
MessageFailureException: Processing of message #id-42 is stopped because of an exception:
assert($message instanceof SendEmailMessage).
With zend.assertions=-1, the production default:
Warning: Undefined property: Yiisoft\Queue\Message\IdEnvelope::$to
sending to: NULL
No error, and the work is done against empty values. DelayEnvelope and FailureEnvelope behave the same way. Call path: Worker.php:45 → ConsumeMiddlewareDispatcher → ConsumeFinalHandler.php:21.
Worth deciding which contract is meant:
- unwrap in
Workerbefore dispatching, so a handler always receives the message type it was registered for, and offer the envelope separately to handlers that want the metadata, or - keep passing the envelope and change every handler example in the guide to unwrap first (
$message instanceof Envelope ? $message->getMessage() : $message), sinceassert()is not a guard in production.
InMemoryAdapter happens not to trigger this because it stores the unwrapped message, but any adapter that stores what push() returned does.
#338 reworks Worker and the pipeline around it, so this probably wants deciding before that lands.
- Langage dominant
- PHP
- Étoiles
- 61
- Forks
- 31
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de yiisoft/queue
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
-
Difficulté 4/5 1-2 jours Accessibilité débutants 47/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 54/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
Toutes les issues de yiisoft/queue
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Featured image not passed to checks in the Tasks column or publish blocksPeut-être pris @roborourke l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
humanmade/publication-checklist#100 ·
Les mainteneurs répondent en général sous 1 jour
-
bug customer-reported
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
MagnaCapax/PMSS#1072 ·
Les mainteneurs répondent en général sous 5 jours
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
hestiacp/hestiacp#5800 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 Une demi-journée Accessibilité débutants 68/100
components-web-app/docs#244 ·