Skip to content

M13 — choose the Messenger buses where the middleware is installed - #279

Open
gplanchat wants to merge 1 commit into
mainfrom
fix/middlewares-bus-choisis
Open

M13 — choose the Messenger buses where the middleware is installed#279
gplanchat wants to merge 1 commit into
mainfrom
fix/middlewares-bus-choisis

Conversation

@gplanchat

@gplanchat gplanchat commented Sep 4, 2026

Copy link
Copy Markdown
Owner

The bundle's middleware went in at the head of every Messenger bus in the application, with no way out.

What was not at fault

Two things the pass does that stay, because they are right:

  • Being at the head. A lock must wrap what follows, doctrine_transaction included — releasing it before the commit would reopen the window it closes.
  • Going through a compiler pass. Symfony has no messenger.middleware tag: nothing calls findTaggedServiceIds() on it, and a service carrying it would be defined and never installed, silently. The pass's docblock already documented this, and history bears it out — that is exactly what had happened to the resume lock.

The defect is the scope, and nothing else.

What it cost

The DBAL resume lock takes a lock per execution, and the profiling middleware measures. Installing them on an application's business command bus — which carries no durable message — is work and a contention point nobody asked for, on a bus whose author does not even know Durable is in the stack.

The fix

durable:
    messenger:
        buses:
            - messenger.bus.durable

The default remains every bus, deliberately: the bundle does not know which bus the application routes ResumeWorkflowMessage to. Narrowing it on our own initiative would remove the lock from the bus actually carrying the work — a silent loss of durability, precisely what that lock exists to prevent. No application is affected without asking for it.

An unknown identifier is refused at compile time, with the list of declared buses:

durable.messenger.buses names "messenger.bus.typo", which is not a Messenger bus of this application. Declared buses: messenger.bus.durable. A bus identifier is a service identifier — "messenger.bus.default" for FrameworkBundle's default bus.

Letting the typo through would have produced the very silence we are trying to remove: the configuration looks set, nothing gets installed. That is the failing the audit points at everywhere else in this bundle.

Three cases

Case What it keeps
no configuration, two buses both are served — regression net, and it already passed before the fix
a list of one bus, two buses declared only the named one is served
a list naming a non-existent bus refused at compile time, message naming the culprit

Coordination with #277

The cases go into a new file rather than into DurableMiddlewareReachesTheBusTest, which #277 already modifies — no point adding a conflict. And my test's container places lock.factory, whose check #277 introduces, so that merging the two goes smoothly whatever the order.

Verification

main this branch
unit suite 1073 tests, 4 errors 1076 tests, 4 errors
PHPStan 2 errors 2 errors

Pre-existing and identical errors (illuminate/cache missing on this machine).

The configuration reference carries the new node, in both languages, with the reason for the default rather than just the syntax.

`RegisterDurableMiddlewarePass` insérait les middlewares du bundle en tête de **tous**
les bus de l'application, sans échappatoire. Le verrou de reprise du backend DBAL prend
un verrou par exécution et le middleware de profil mesure : les appliquer au bus de
commandes métier, qui ne transporte aucun message durable, c'est du travail et un point
de contention que personne n'a demandés.

Ce qui n'était pas en cause, et ne bouge pas : être en tête — un verrou doit envelopper
ce qui suit, `doctrine_transaction` compris — et passer par une passe, faute de balise
`messenger.middleware` chez Symfony, ce que le docbloc de la passe explique déjà.

`durable.messenger.buses` nomme les bus à servir. Le défaut reste **tous**, et ne peut
pas être plus fin : le bundle ne sait pas vers quel bus l'application route
`ResumeWorkflowMessage`, et deviner retirerait le verrou du bus qui porte réellement le
travail — une perte de durabilité silencieuse, exactement ce contre quoi ce verrou
existe. Aucune application n'est donc touchée sans le demander.

Un identifiant qui ne nomme aucun bus déclaré est refusé à la compilation, avec la liste
de ceux qui existent. Laisser passer la faute de frappe produirait le silence qu'on
cherche à supprimer : la configuration a l'air posée, rien ne s'installe.

Les cas vont dans un fichier neuf plutôt que dans `DurableMiddlewareReachesTheBusTest`,
que la PR #277 modifie déjà ; le conteneur du test pose `lock.factory` pour que la
fusion des deux se passe sans heurt.

Suite unit : 1076 tests contre 1073 sur main, mêmes 4 erreurs d'environnement. PHPStan :
2 erreurs, la base de main.

Refs: M13 de documentation/audit/

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gplanchat gplanchat changed the title M13 — choisir les bus Messenger où les middlewares s'installent M13 — choose the Messenger buses where the middleware is installed Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant