It's not a bug, it's a feature :) You probably missed [this](https://nim-lang.github.io/Nim/manual.html#closures-creating-closures-in-loops) part of the manual where it is explained that closures capture variable by reference. In your example the inner `serve` captures `c` by reference and, as a result, you're always listening on the last accepted connection. To solve this problem you can just create a local copy of `c` and use it.
- Unexpected async behaviour? dawkot
- Re: Unexpected async behaviour? dom96
- Re: Unexpected async behaviour? dawkot
- Re: Unexpected async behaviour? lemonboy
- Re: Unexpected async behaviour? dawkot
- Re: Unexpected async behaviour? cdunn2001