tailscale-dev/vscode-tailscale

SFTP resource leak leading to excessive node memory usage

Opened this issue · 1 comments

Hey there,
I really like the extension!

I was using it for longer sessions to edit files on my remote Linux node and I noticed that its memory usage was creeping up slowly. In the span of 4 hours more than 500 of these processes spawned and was kept around for as long as vscode was open. These were eating up around 2 GB of my node's RAM by the time I noticed:

/usr/sbin/tailscaled be-child ssh [...] --has-tty=false --tty-name= --sftp

I looked around a bit in the extension source - I see that ssh connections are cached in the SshConnectionManager but on each SFTP command a new SFTP session is created via new Sftp(conn) / conn.sftp. Every time any SFTP related action is performed in the node explorer a new process is spawned on the remote host. I messed around and tried explicitly closing the sftp sessions with sftp.end() that seemed to solve the issue (caching should also work).

I'm running Linux both locally and on the node, Tailscale v1.48.1, extension v0.6.2.

Thanks for the report @Szilard95 - I have figured out the issue with the connection re-use and am working on a fix.