Sublime Forum

SFTP long freeze editing network files on command palette / right click

#1

I guess this post is primarily for Will @wbond the author of SFTP. Hi Will :slight_smile:

I’ve been having a longstanding issue in Sublime with the command palette and/or right click menu causing occasional long freeze (but not crash). The problem has been sporadic and upon investigation today with a portable Sublime install I found the culprit: SFTP.

Steps to repeat:

  1. Install a portable Sublime (Win x64 in my case)
  2. Install package control then SFTP
  3. Edit a file on a samba share. In my case using Win explorer I’m dragging the file ‘composer.json’ from a share that looks like \servername\share\project\composer.phar
  4. Right click on the file or press ctrl+shift+p to bring up the command palette.

With SFTP installed I notice the command pallete / right click menu appears more slowly than usual. But quite often, usually after alt+tabbing back to Sublime from spending some time on a chrome window, a right-click and/or ctrl+shift+p sublime will freeze Sublime for a long period (20s+). Windows brings up the ‘not responding’ box and the Sublime window grays out. Eventually, Sublime will come back to life, but either right-click-on-file or c+s+p will freeze it again.

Disabling SFTP in package control completely clears the problem, and palette or right-click menus appear instantly.

I also have this issue in my ‘main’ copy of Sublime when I load up a project whose files exist on \server\share\project. Would love to see this fixed; I’m having to repeatedly disable and enable SFTP at the moment. Will?? :wink:

0 Likes

#2

Yes, the culprit here is that the commands for SFTP are only “enabled” if the file is within a directory containing an sftp-config.json file. To check this, I walk the folder structure up looking for one. With a slow filesystem, this will definitely cause freezes.

Unfortunately there is no way to rely on filesystem notifications on a laggy filesystem, since they are inevitably a Samba connection or an SSHFS.

What I’ll have to do is cache known sftp-config.json locations, and have a background thread that periodically walks the filesystem to make sure they still exist. When initially showing the command palette, I’ll have to assume SFTP is configured, fire off a background thread to check, and if the user invokes a command during a pending check, wait to see if SFTP should actually be available.

Unfortunately this will end up being a little messy with the context menu in the sidebar, but alas that is just how it will have to be.

1 Like

#3

Thanks Will. But the strange thing here is that the server in question is on a gigabit LAN and very zippy generally. Of course it is slow compared to a local filesystem, but I can’t imagine walking up a couple of folder levels to check for a file would lag by much. It explains the slight delays seeing the context menu / palette, but doesn’t explain the long 30s freezes.

Might another approach be to simply disable this functionality when the current file is nonlocal? I suppose this might be harder to establish on POSIX filesystems where nonlocal filesystems could be mounted into the local filesystem, but could probably be established by blacklisting locations established as such from the mountpoint list.

Another alternative would be to provide a config option to disable that side of SFTP altogether (presumably it’s used where FTP directories are mirrored locally - a feature I don’t personally use), or provide configurable white/blacklists?

Thanks for your help - it’s taken me a while to nail this down :roll_eyes:

0 Likes