Repository navigation
v2.25.9
Patch release. A pull consumer's stop() or drain() now ends the run at once while it is still setting up its pull inbox during a reconnect, returning 0. Before, the run waited for the reconnect or failed with a subscribe timeout (#198).
Upgrading is recommended for workers that may start handle() while the connection is reconnecting and get shut down meanwhile, for example a SIGTERM during a rolling restart of the NATS cluster. There are no API changes. symfony-nats-messenger, which runs with reconnect off, is not affected.
Fixed
-
stop()anddrain()end the inbox set-up at once (#198). #181 (2.17.0) made the iterator'sstop()anddrain()from another fiber end the engine's pump read and idle backoff at once. It missed the run's first wait: the subscribe of its pull inbox, which can wait for a reconnect, for theSUBwrite, and for the recovery of a failed write. A run told to stop during an outage kept waiting:- When the reconnect came back, the run subscribed its inbox on the new connection only to release it again.
- When it did not come back within
requestTimeoutMs(10 s by default),handle()failed with the subscribe'sTimeoutException, although the run had been told to stop. A supervisor that treats a failed run as an error saw one.
The set-up now waits with the run's stop and drain wake-ups next to its budget:
- A stop or drain during the set-up ends it at once. The run returns 0 with no pull issued, so nothing is delivered or lost.
- Cleanup: the cancelled subscribe releases what it registered. A
SUBnot yet written is never written, one waiting for the recovery is not replayed, and one already written or replayed is followed by itsUNSUBon that session. The shared reconnect carries on for other operations. - A signal latched before the engine starts skips the subscribe entirely.
- Without a signal the set-up still waits for the reconnect within its budget and then pulls.
- When the budget runs out, an inbox rejection the server sent meanwhile (permissions, or the connection's subscription limit) still fails the run with its detailed error. With a signal the run returns 0.
- A connection failure is not turned into a normal end by a signal that arrives after it.
This is the iterator's
drain(); draining the client is unchanged.
Before upgrading
- A pull consumer run's inbox set-up now has one
requestTimeoutMsbudget for all of it: the reconnect wait, theSUBwrite and the recovery of a failed write. It used to have up to two freshrequestTimeoutMswaits and an unboundedSUBwrite. - When that budget runs out without a signal,
handle()still fails with aTimeoutException. The message now readsSubscribe to "_INBOX.JS.PULL.<nuid>.*" timed out within the operation budget; it used to read... timed out waiting for the connection to be re-established. Publicsubscribe()is unchanged. - A run stopped before its engine started no longer subscribes an inbox only to release it at once.
Quality gates
- PHPStan level 8.
- 3416 unit tests (with data sets) on PHP 8.2 to 8.5, 157 live integration tests and 49 Behat scenarios. All runnable examples pass.
codecov/patch100%: every changed line is covered. Total coverage 99.03%.- Infection covered MSI 92.79% (90% floor enforced in CI). It skipped 4913 of the 8796 mutants it generated as too slow, so the score does not include them. No mutant escaped in the new set-up code.
- New
PullConsumerSubscribeWakeUpTest, 28 cases: the issue's 26, of which 20 fail on 2.25.8, plus two more. They cover a latched signal that starts no subscribe, and a stop or drain that lands after the connection failed, which must not turn the failure into 0. Eight broken variants of the fix each fail at least two cases. - The startup regression in
PullConsumerWakeUpTestnow expects oneSUBand noUNSUB.
The full record is in the CHANGELOG.