Fix leak in server acceptLoop

Merged Cecylia Bocovich requested to merge cohosh/snowflake:fix/40052 into main

Refactor out a separate handleStream function and ensure that all connections are closed and the references are out of scope.

Hopefully closes #40052 (closed)

Merge request reports