nats-io / nats.net

Full Async C# / .NET client for NATS
https://nats-io.github.io/nats.net
Apache License 2.0
268 stars 55 forks source link

INatsKVStore.GetKeysAsync cause connection leak #621

Open Bykiev opened 2 months ago

Bykiev commented 2 months ago

Observed behavior

Calling await foreach (var key in store.GetKeysAsync()) cause connection leak

Expected behavior

No connection leak should be occured

Server and client version

NATS server 2.10.19 NATS .NET v2.3.3

Host environment

Docker image

Steps to reproduce

No response

mtmk commented 2 months ago

it might be an issue with KV watcher push consumer buffer causing ahead-of-time issues:

https://github.com/nats-io/nats.net/blob/a8daa4bdad7a2cb1db8b3b6552cd663b9f43f98a/src/NATS.Client.JetStream/Internal/NatsJSOrderedPushConsumer.cs#L115

mtmk commented 1 month ago

@Bykiev are you able to create a simple console app to reproduce this? I need to understand the issue a bit more my comment above might not apply here actually.