Repository navigation
v2.22.0
Minor release. A JetStream pull consumer run, PullConsumerIterator::handle(), that ends with an error now hands its handler the messages its pulls had already received before it throws (#197). Before, those messages were dropped with the run: the server counted them as delivered, so they came again only after ack_wait, and never on a consumer with ack_policy: none or max_deliver: 1.
Upgrading is recommended if you run pull consumers with setBatching() above 1 and reconnect off, waitForReconnect: false, or a consumer without acks. There are no API changes. What changes for a run that ends with an error (its read or a pull's write failing because the connection is going, a fatal -ERR, the server rejecting its reply inbox, or a failure handlerErrorsFailOperations or slowConsumerErrorsFailOperations makes the read's own):
- The handler runs for the messages the pulls had received, in the order they arrived, and
handle()then throws the same error as before. - On a closed connection the handler's acks fail. A handler that throws during that hand-over, as one that lets a failed ack out does, ends it, and its exception goes to the error listener and the logger instead of out of
handle(). - A
stop()still leaves those messages unhandled, and so does closing the connection yourself withdisconnect()or the client'sdrain(): drain the iterator and awaithandle()before you close the connection.
symfony-nats-messenger fetches with fetchBatch(), not the pull consumer iterator, and works with this release unchanged.
Fixed
- A pull consumer run that ended with a failure of its own read or of a pull's write dropped the messages its pulls in flight had received (#197). The engine hands a pull's messages to the handler only when it retires the pull (its batch full, a status from the server, or its deadline), so between those points a pull holds messages the handler has not seen. A run that failed meanwhile, finite or infinite, dropped them. Such a run now hands them over in issue order, with
stop()checked before each message, and then throws its error unchanged, asfetchBatch()returns its partial batch since 2.21.0. On nats-server 2.12 with reconnect off, the client's TCP connection cut while a pull held the stream's two messages: on a consumer withack_policy: none2.21.0 lost both for good; 2.22.0 hands both to the handler beforehandle()throwsReconnect is disabled. An infinite run that goes on through a reconnect still discards what its pulls held at the reconnect; that is #187.
Quality gates
- PHPStan level 8.
- 2980 unit tests (with data sets) on PHP 8.2 to 8.5, 149 live integration tests and 48 Behat scenarios.
- All 45 runnable examples executed against a live server.
- Statement coverage 98.83% from the unit suite (95% floor enforced in CI) and 98.90% combined (97% floor).
- Infection covered MSI 92.6% over the 3990 mutants it ran (90% floor enforced in CI); it skipped 4080 of the 8070 it generated as too slow, so the score does not include them.
- Every change has tests that fail on the old code. 32 new test cases, decided by the order of events: 25 fail on 2.21.0, and the other 7 pin what must not change.
- The change was reviewed for semantics and for interleavings by two independent reviewers, and their findings were applied.
- symfony-nats-messenger's main branch against this release: PHPStan level max, 528 unit tests, 52 functional scenarios against live NATS and 5 examples pass.
The full record is in the CHANGELOG.