Files
mirror-3x-ui/internal/tuic
Sanaei de7ef54739 fix(tuic): keep a UDP association when the peer stops one response stream
In stream mode every UDP response travels on its own unidirectional stream.
A client that reads the packet by its declared size and then drops the
stream sends STOP_SENDING. When that arrived before the server's Close, or
while a large response was still being written, the write path returned an
error, the response reader exited and the whole association was released:
later packets on it were answered on the wrong transport or not at all.

A stop from the peer now ends that one packet only. Close reports it as an
untyped error, so the stream's own cancel cause is what is checked.

This is also the flake that turned main's CI red three times, in
TestAudit3UDPAssociationMustRecoverAfterBridgeReadFailure/stream and
TestAudit3FirstTransportReturnsPositiveEchoAfterOppositeModePacket/stream-first:
their helper cancels the read after each packet, and a loaded runner lost the
race between Write and Close. Sleeping 50 ms between the two reproduces both
failures on the old code every run and none with this change.

The recovery test also matched its log line by a tag reused across runs, so
any -count above 1 passed its wait on the previous run's line; the tag is
now unique.
2026-11-25 11:02:24 +03:30
..