4 ms·
> The bug is that there's not a closure around the ssh instance, so if you call this function multiple times it'll actually return the same connection instance.
by plorkyeran 3y ago
> The bug is that there's not a closure around the ssh instance, so if you call this function multiple times it'll actually return the same connection instance.
You've either adjusted the code for posting or you misunderstood what the problem was, because no, that's not the case. The ssh variable is local to the getSFTPConnection function and is not reused between multiple calls to the function, and throwing a pointless extra closure in there wouldn't do anything.