diff --git a/nestsClient/src/commonMain/kotlin/com/vitorpamplona/nestsclient/moq/lite/MoqLiteSession.kt b/nestsClient/src/commonMain/kotlin/com/vitorpamplona/nestsclient/moq/lite/MoqLiteSession.kt index be47b28baa..fa8dfaf59c 100644 --- a/nestsClient/src/commonMain/kotlin/com/vitorpamplona/nestsclient/moq/lite/MoqLiteSession.kt +++ b/nestsClient/src/commonMain/kotlin/com/vitorpamplona/nestsclient/moq/lite/MoqLiteSession.kt @@ -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 }