Skip to content

v2.26.7

Choose a tag to compare

@bpacholek bpacholek released this 13 Oct 17:47
· 47 commits to main since this release

Patch release.

Fixed

A chunk that a custom transport hands over late now stays on the connection its read started on (#205). "Late" means after that connection was replaced by a reconnect, or closed. The chunk is parsed with that connection's parser and dispatched as that connection's frames.

Before, the late bytes went into the new connection's parser and were treated as the new server's:

  • the old server's PING was answered on the new connection;
  • its PONG, or a late reply, could confirm the new connection's reply inbox;
  • its INFO replaced the new server's info;
  • a partial frame left the new parser expecting payload, so the new server's next PING was swallowed and never answered.

Now the whole late chunk follows the rule the client already applies to the rest of a lame-duck chunk (#182):

  • its messages go to the subscriptions the reconnect replayed;
  • its PING, PONG and INFO are not applied to the new connection;
  • its -ERR is reported as the old server's.

If the late chunk ends in corrupt bytes, the client still reports the parse failure and delivers the messages ahead of them. It does not start or join a recovery of the new connection. The heartbeat's read follows the same rules.

Who should upgrade: anyone with their own TransportInterface implementation whose readLine() can complete after close() and a new connect(). The built-in AmpSocketTransport and WebSocketTransport can't, because their close() ends a pending read. There are no API changes.

Before upgrading

  • New in the TransportInterface::readLine() docblock: a read belongs to the connection it started on. End pending reads when close() ends that connection. Never return one connection's bytes from a read started on another. Start each connect() with fresh buffers. The client's new handling covers a late read, but it can't separate bytes that a read started on the new connection receives from the old one.

Quality gates

  • PHPStan level 8.
  • 3642 unit tests (with data sets) on PHP 8.2 to 8.5, 159 live integration tests and 49 Behat scenarios. All runnable examples pass.
  • codecov/patch 100%: every changed line is covered. Total coverage 99.05%.
  • Infection covered MSI 92.83% (90% floor enforced in CI). It skipped 4965 of the 8856 mutants it generated as too slow, so the score does not include them. No mutant escaped in the changed lines.
  • New LateTransportReadTest, 35 cases over a transport that holds a read across a reconnect, 31 of which fail on 2.26.5.
  • Seven incomplete versions of the fix were tried, and each one fails cases. Each of the following was left out in turn: the parser capture, the dispatch origin (once in full, and once only for frames kept after a parse error), the close count in the dispatch, the stale-recovery guard and the heartbeat guard. The seventh made dispatchFrames() ignore the passed origin. One more variant passes the whole unit suite: the recovery guard checking the generation alone, without the close count. It differs only after a terminal close, where recovery cannot run, so that half of the guard is kept as defensive code.

The full record is in the CHANGELOG.