Throwing Exceptions inside a coroutine causes reactor to go on an infinite loop

I have the following code which attempts to process a kafka message, and if it fails, logs/publish it to another topic for later processing.

@Service
class KafkaConsumerService(
    private val kafkaService: KafkaService
) {

    @KafkaListener(topics = ["my-topic"], groupId = "my-group")
    fun listenToTransactionTopic(msg: ConsumerRecord<String, DynamicMessage>, ack: Acknowledgment) = runBlocking {
        val message: ProtoMessage = ProtoMessage.parseFrom(msg.value().toByteArray())

        try {
            kafkaService.process(message)
        } catch(e:Exception){
          // publish to another topic
        }
        finally {
            ack.acknowledge()
        }
    }
}

@Service
class KafkaService(
    private val myentityService: MyEntityService,
    private val kafkaMapper: KafkaMapper.
) {

    companion object {
        private val logger = LoggerFactory.getLogger(KafkaService::class.java)
    }

    @Transactional("transactionManager")
    suspend fun process(message: ProtoMessage) {
        val myEntity = myentityService.saveEntity(
            kafkaMapper.map(message)
        )

    // save other var to db by calling other suspend functions

        // produce another message
        withContext(Dispatchers.IO) {
            // write a message to a toic
        }
    }

}

class KafkaMapper(
    private val clientService: clientService,
) {
    companion object {
        private val logger = LoggerFactory.getLogger(KafkaMapper::class.java)
    }

    suspend fun map(message: ProtoMessage): MyEntity = coroutineScope {

        // expecting a list back
        val remoteCall = clientService.someRemoteCall().awaitSingle() 
    // this uses webApi ==> webClientBuilder.baseUrl(url).filter(oauth2Filter).observationRegistry(observationRegistry).build()

        if (remoteCall.size =! 1) {
            logger.error("Failed :(")
            throw IllegalStateException(error) // this causes inifinte loop if thrown enough times
        }

        return remoteCall.first()
    }
}

The problem started to arise when I used reactive client to call my other webservices and if I throw any exception from within the mapper function:

java.lang.StackOverflowError: null
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.MonoFlatMap$FlatMapInner.currentContext(MonoFlatMap.java:270)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.MonoFlatMap$FlatMapInner.currentContext(MonoFlatMap.java:270)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.MonoFlatMap$FlatMapInner.currentContext(MonoFlatMap.java:270)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.MonoFlatMap$FlatMapInner.currentContext(MonoFlatMap.java:270)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.MonoFlatMap$FlatMapInner.currentContext(MonoFlatMap.java:270)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.MonoFlatMap$FlatMapInner.currentContext(MonoFlatMap.java:270)
    at reactor.core.publisher.InnerOperator.currentContext(InnerOperator.java:33)
    at reactor.core.publisher.InnerOperator.currentContext ... 1000+ lines

Also my kafka transactions started to fail when I used reactive clients. What is causing the reactive infinite loop?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật