fix(nestsClient): write Ended announce when publisher.close() races registerAnnounceBidi

When publisher.close() acquires the gate lock before registerAnnounceBidi,
the announce bidi list is empty and no Ended message is sent. Fix by writing
Ended + finishing the bidi in registerAnnounceBidi when publisherClosed is
already true, mirroring what close() does for bidis it owns at close time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015t3bsJruGerz53yafZyp9n
This commit is contained in:
Claude
2026-06-22 15:56:26 +00:00
parent 59361c378e
commit 03aac0025d
@@ -1398,6 +1398,20 @@ class MoqLiteSession internal constructor(
) {
gate.withLock {
if (publisherClosed) {
// publisher.close() raced ahead — write Ended now so
// the relay sees the proper lifecycle close on this bidi.
runCatching {
bidi.write(
MoqLiteCodec.encodeAnnounce(
MoqLiteAnnounce(
status = MoqLiteAnnounceStatus.Ended,
suffix = emittedSuffix,
hops = emptyList(),
),
version,
),
)
}
runCatching { bidi.finish() }
return
}