vscode-sftp: SFTP error upload no such file after update VS code 1.56.0

Issue Type: Bug

while upload a file from local to remote, it show an error no such file and connection time out 10000. but the file is uploading without problem, just showing an error. This happen because I am update VS code version to 1.56.0.

Extension version: 1.12.9 VS Code version: Code 1.56.0 (cfa2e218100323074ac1948c885448fdf4de2a7f, 2021-05-04T22:09:06.405Z) OS version: Windows_NT x64 10.0.19041

System Info
Item Value
CPUs Intel® Core™ i5-7200U CPU @ 2.50GHz (4 x 2712)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 11.87GB (5.66GB free)
Process Argv –crash-reporter-id 1ad20214-094e-4571-829c-44d1a08acd9f
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
pythonvspyt602cf:30294773
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30291489
pythontb:30283811
pythonvspyt551:30291414
vspre833cf:30267465
pythonptprofiler:30281270
vscnewfiletext:30294816
vshan820:30294714
pythondataviewer:30285071
vscus158:30286553
vscgsv2ct:30294353

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 87
  • Comments: 122

Most upvoted comments

In the same way, add options.autoDestroy = false; in the ReadStream function

Nice - thanks @sdir. Guess I could have figured that if I thought about it.

So to sum up all the above as TLDR for others skimming this thread:

  1. Do a search inside ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js for options.emitClose = false;

  2. Add options.autoDestroy = false; after both instances.

stream.Writable Change autoDestroy option default to true in Nodejs V14. add code

function WriteStream(sftp, path, options) {
  if (options === undefined)
    options = {};
  else if (typeof options === 'string')
    options = { encoding: options };
  else if (options === null || typeof options !== 'object')
    throw new TypeError('"options" argument must be a string or an object');
  else
    options = Object.create(options);

  // For backwards compat do not emit close on destroy.
  options.emitClose = false;
  options.autoDestroy = false;

  WritableStream.call(this, options);

To elaborate on this, I believe @sdir is suggesting to add options.autoDestroy = false; to SFTP.js (refer to lines 3387-3400), which is a part of the ssh2 package.

In the context of liximomo/vscode-sftp, it looks like this is part of ssh2-streams, and you’d want to update:

~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js

I can confirm that this also works to resolve the issue when running VS Code 1.56.0.

image

You’ll find the NodeJS release notes here which documents the change in default behaviour of autoDestroy. It was changed in this commit as part of this pull request. Per the comment changes as part of that commit, streams are now closed when an error event is emitted, unless the autoDestroy option is set to false when first creating the stream.

Editing the file: ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js change the line 388: if (code === STATUS_CODE.OK) { to: if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) { Reload vscode It is not the most correct option but it works.

stream.Writable Change autoDestroy option default to true in Nodejs V14. add code

function WriteStream(sftp, path, options) {
  if (options === undefined)
    options = {};
  else if (typeof options === 'string')
    options = { encoding: options };
  else if (options === null || typeof options !== 'object')
    throw new TypeError('"options" argument must be a string or an object');
  else
    options = Object.create(options);

  // For backwards compat do not emit close on destroy.
  options.emitClose = false;
  options.autoDestroy = false;

  WritableStream.call(this, options);

I’ve made a pull request on ssh2-streams repo to (temporary) fix this error : mscdex/ssh2-streams#174

Can not work after local installation.

You have to manually update it. There are two easy ways of doing it :

Method 1) a. download my modded v0.4.11 ssh2-streams module version from HERE ! b. go to $HOME/.vscode/extensions/liximomo.sftp-1.12.9/node_modules. (on Windows replace $HOME with %UserProfile%). c. delete “ssh2-streams” folder. d. extract here the downloaded archive (modded v0.4.11 ssh2-streams version). e. you should now have $HOME/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams (on Windows replace $HOME with %UserProfile%). d. restart Visual Studio Code.

Method 2) a. go to $HOME/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib. (on Windows replace $HOME with %UserProfile%). b. open sftp.js file. c. search for “options.emitClose = false;” d. add “options.autoDestroy = false;” after both instances. e. restart Visual Studio Code.

image

Yeah this is annoying. And I’m not hoping for an update with 311 issues listed and the last commit 2 years ago… Is this extension abandoned?

Just use my version (v1.13.0) that implement the new ssh2 v1.1.0 version that fix every problem 🙂 https://github.com/Natizyskunk/vscode-sftp/releases

Updating the SSH2 package has fixed the issue for me, just need to change the ssh2 version 1.1.0 in the package.json "extensions/liximomo.sftp-1.12.9/package.json, and run npm install, https://www.npmjs.com/package/ssh2

@shivam-geek solution works for me. (Windows 10) in ~.vscode\extensions\liximomo.sftp-1.12.9\package.json change “ssh2”: “^x.x.x” to “ssh2”: “^1.1.0” then run in .vscode\extensions\liximomo.sftp-1.12.9> npm install

+1

Guys, please use 👍🏻 emoji on the comment you want to +1, instead of “+1” or a text such as “same problem” as a comment.

Same issue here under version 1.12.9, pop up “No such file error” while uploading file to remote, but actually the file has been successfully uploaded.

Be careful with it, some times, when you update file, is can come empty. And if update folder, some files can be empty, some files may contain text from other files. I downgraded my VSCode to previous version

For now, you can change protocol from sftp to ftp, and port from 22 to 21. Just until get update 😃

Updating the SSH2 package has fixed the issue for me, just need to change the ssh2 version 1.1.0 in the package.json "extensions/liximomo.sftp-1.12.9/package.json, and run npm install, https://www.npmjs.com/package/ssh2

VSCode was recently bumped to node v14. I looked deeper into other packages (ssh2, ssh2-streams) and it lead me to ssh2-sftp-client package. In the overview it says that the node itself had some changes with streams that causes these errors. Node v15.3 had additional changes (or a rollback) that fixes the issue.

In any way, this extension uses ssh2 and probably that’s where the code should be updated and errors handled to work with node v14. I tried updating ssh2 package on this extension, but it didn’t seem to help either. Most likely we’ll have to wait until VSCode node is bumped to v15.

I’ve made a pull request on ssh2-streams repo to (temporary) fix this error : https://github.com/mscdex/ssh2-streams/pull/174

stream.Writable Change autoDestroy option default to true in Nodejs V14. add code

function WriteStream(sftp, path, options) {
  if (options === undefined)
    options = {};
  else if (typeof options === 'string')
    options = { encoding: options };
  else if (options === null || typeof options !== 'object')
    throw new TypeError('"options" argument must be a string or an object');
  else
    options = Object.create(options);

  // For backwards compat do not emit close on destroy.
  options.emitClose = false;
  options.autoDestroy = false;

  WritableStream.call(this, options);

To elaborate on this, I believe @sdir is suggesting to add options.autoDestroy = false; to SFTP.js (refer to lines 3387-3400), which is a part of the ssh2 package. In the context of liximomo/vscode-sftp, it looks like this is part of ssh2-streams, and you’d want to update:

~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js

I can confirm that this also works to resolve the issue when running VS Code 1.56.0. image You’ll find the NodeJS release notes here which documents the change in default behaviour of autoDestroy. It was changed in this commit as part of this pull request. Per the comment changes as part of that commit, streams are now closed when an error event is emitted, unless the autoDestroy option is set to false when first creating the stream.

Thanks! It’s now working perfectly! At the same time, the following problems are also solved

When I use the Upload Folder directives to upload a folder, some files will fail to upload. This situation did not exist before VSCode was updated.

This workaround works indeed. But I think should update code somewhere in this extension (vscode-sftp),may be set default options for calling the function WriteStream() in sftp.js.

options.autoClose default false but autoDestroy not change. Maybe a bug for ssh-stream library.

This fix seemed to solve the issue with uploading to FTP but downloads are still generating the error. Does anyone know if there’s perhaps another instance of this code that needs adjusting in the same way for downloads/sync ations?

In the same way, add options.autoDestroy = false; in the ReadStream function

Editing the file: ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js change the line 388: if (code === STATUS_CODE.OK) { to: if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) { Reload vscode It is not the most correct option but it works.

Fork it and PR. Maybe author will at least accept it as even if it’s not perfect.

In the same way, add options.autoDestroy = false; in the ReadStream function

Nice - thanks @sdir. Guess I could have figured that if I thought about it.

So to sum up all the above as TLDR for others skimming this thread:

  1. Do a search inside ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js for options.emitClose = false;
  2. Add options.autoDestroy = false; after both instances.

This is Perfect, I worked for me without downgrade

Just downgrade to VSC 1.55 in my opinion. Best solution to this issue

Best solution for today, but how about a year from now?

Just downgrade to VSC 1.55 in my opinion. Best solution to this issue

Well, just now I went to the remote server to have a look. Although it was said that there was an error prompt of no such file, the remote file has been updated, which does not affect the use.

Please please… Release an update!

Editing the file: ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js change the line 388: if (code === STATUS_CODE.OK) { to: if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) { Reload vscode It is not the most correct option but it works.

work for me ,thx!

Guys, it’s most likely because of a regression on streams in the Node version that VSCode uses in 1.56.0

Also this extension is pretty much a wrapper of ssh2 package, so not much can be done here.

It will be very sad to find out that the plugin has been abandoned 😦 I did not find a worthy alternative

@IlanVivanco,

@Natizyskunk are you planning to maintain the new fork?

Yes for sure, i’ll try my best to keep it up to date and to fix most of the problems people will come across.

image

The same problem

Version: 1.56.0 (user setup) Commit: cfa2e218100323074ac1948c885448fdf4de2a7f Date: 2021-05-04T22:09:06.405Z Electron: 12.0.4 Chrome: 89.0.4389.114 Node.js: 14.16.0 V8: 8.9.255.24-electron.0 OS: Windows_NT x64 10.0.19041

Updating the SSH2 package has fixed the issue for me, just need to change the ssh2 version 1.1.0 in the package.json "extensions/liximomo.sftp-1.12.9/package.json, and run npm install, https://www.npmjs.com/package/ssh2

@shivam-geek solution works for me. (Windows 10) in ~.vscode\extensions\liximomo.sftp-1.12.9\package.json change “ssh2”: “^x.x.x” to “ssh2”: “^1.1.0” then run in .vscode\extensions\liximomo.sftp-1.12.9> npm install

it works

@lackneets, As i’ve stated above :

Just use my version that implement the new ssh2 v1.1.0 version that fix every problem 🙂 https://github.com/Natizyskunk/vscode-sftp/releases

@lighthousebulb Yeah… read @Natizyskunk’s post.

+1

I downgraded my vscode to previous version. ( 1.55.2 ) It works well. And disabled automatic update. I will use this version until this is fixed.

download : https://code.visualstudio.com/updates/v1_55

Have the same Problem 😦

+1

Having the same issue. The extension is reporting error but the file is successfully uploaded to remote server:

image

[05-06 11:11:10] [error] Error: No such file at SFTPStream._transform (c:\Users\USER.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2-streams\lib\sftp.js:412:27) at SFTPStream.Transform._read (internal/streams/transform.js:205:10) at SFTPStream._read (c:\Users\USER.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2-streams\lib\sftp.js:183:15) at SFTPStream.Transform._write (internal/streams/transform.js:193:12) at writeOrBuffer (internal/streams/writable.js:358:12) at SFTPStream.Writable.write (internal/streams/writable.js:303:10) at Channel.ondata (internal/streams/readable.js:719:22) at Channel.emit (events.js:315:20) at addChunk (internal/streams/readable.js:309:12) at readableAddChunk (internal/streams/readable.js:284:9) at Channel.Readable.push (internal/streams/readable.js:223:10) at SSH2Stream.<anonymous> (c:\Users\USER.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2\lib\Channel.js:167:15) at SSH2Stream.emit (events.js:315:20) at parsePacket (c:\Users\USER.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2-streams\lib\ssh.js:3288:10) at SSH2Stream._transform (c:\Users\USER.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2-streams\lib\ssh.js:694:13) at SSH2Stream.Transform._read (internal/streams/transform.js:205:10) at SSH2Stream._read (c:\Users\USER.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2-streams\lib\ssh.js:253:15) at SSH2Stream.Transform._write (internal/streams/transform.js:193:12) at writeOrBuffer (internal/streams/writable.js:358:12) at SSH2Stream.Writable.write (internal/streams/writable.js:303:10) at Socket.ondata (internal/streams/readable.js:719:22) at Socket.emit (events.js:315:20) at addChunk (internal/streams/readable.js:309:12) at readableAddChunk (internal/streams/readable.js:284:9) at Socket.Readable.push (internal/streams/readable.js:223:10) at TCP.onStreamRead (internal/stream_base_commons.js:188:23) when local ➞ remote c:\Users\USER\Desktop\WORKDIR\Projects!AUTOMATION\gst_dev\apps\p2mp_inventory.py

liximomo.sftp version v1.12.9

Version: 1.56.0 (user setup) Commit: cfa2e218100323074ac1948c885448fdf4de2a7f Date: 2021-05-04T22:09:06.405Z Electron: 12.0.4 Chrome: 89.0.4389.114 Node.js: 14.16.0 V8: 8.9.255.24-electron.0 OS: Windows_NT x64 10.0.18363

Same problem here. The files have been uploaded successfully. Just ‘set modify time’ seems bugged

@PaPa31,

Why not just use my version. I’ve take over this extension and I’m actively mainting it and adding new features.

You can find it here.

Cheers 😃

Because your version doesn’t work!

I mean the ‘Upload Changed Files’ command doesn’t work.

UNDERSTAND!!!

@Natizyskunk are you planning to maintain the new fork?

For Windows users using WSL (I tested it only with WSL2, but expecting the same results on WSL1):

I’ve made a pull request on ssh2-streams repo to (temporary) fix this error : mscdex/ssh2-streams#174

Nice work - was on my to-do list for this weekend!

https://github.com/liximomo/vscode-sftp/issues/919#issuecomment-833347042

Same here! File upload well with 1 popup error!

Same here!

https://github.com/liximomo/vscode-sftp/issues/919#issuecomment-838586635

In the same way, add options.autoDestroy = false; in the ReadStream function

Nice - thanks @sdir. Guess I could have figured that if I thought about it.

So to sum up all the above as TLDR for others skimming this thread:

  1. Do a search inside ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js for options.emitClose = false;
  2. Add options.autoDestroy = false; after both instances.

Works here too, no more popup error!

stream.Writable Change autoDestroy option default to true in Nodejs V14. add code

function WriteStream(sftp, path, options) {
  if (options === undefined)
    options = {};
  else if (typeof options === 'string')
    options = { encoding: options };
  else if (options === null || typeof options !== 'object')
    throw new TypeError('"options" argument must be a string or an object');
  else
    options = Object.create(options);

  // For backwards compat do not emit close on destroy.
  options.emitClose = false;
  options.autoDestroy = false;

  WritableStream.call(this, options);

To elaborate on this, I believe @sdir is suggesting to add options.autoDestroy = false; to SFTP.js (refer to lines 3387-3400), which is a part of the ssh2 package. In the context of liximomo/vscode-sftp, it looks like this is part of ssh2-streams, and you’d want to update:

~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js

I can confirm that this also works to resolve the issue when running VS Code 1.56.0. image You’ll find the NodeJS release notes here which documents the change in default behaviour of autoDestroy. It was changed in this commit as part of this pull request. Per the comment changes as part of that commit, streams are now closed when an error event is emitted, unless the autoDestroy option is set to false when first creating the stream.

Thanks! It’s now working perfectly! At the same time, the following problems are also solved

When I use the Upload Folder directives to upload a folder, some files will fail to upload. This situation did not exist before VSCode was updated.

This workaround works indeed. But I think should update code somewhere in this extension (vscode-sftp),may be set default options for calling the function WriteStream() in sftp.js.

options.autoClose default false but autoDestroy not change. Maybe a bug for ssh-stream library.

This fix seemed to solve the issue with uploading to FTP but downloads are still generating the error. Does anyone know if there’s perhaps another instance of this code that needs adjusting in the same way for downloads/sync ations?

Editing the file: ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js change the line 388: if (code === STATUS_CODE.OK) { to: if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) { Reload vscode It is not the most correct option but it works.

Thanks! The problem is solved.

Thx! It’s work.

Editing the file: ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js change the line 388: if (code === STATUS_CODE.OK) { to: if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) { Reload vscode It is not the most correct option but it works.

Thanks! The problem is solved.

stream.Writable Change autoDestroy option default to true in Nodejs V14. add code

function WriteStream(sftp, path, options) {
  if (options === undefined)
    options = {};
  else if (typeof options === 'string')
    options = { encoding: options };
  else if (options === null || typeof options !== 'object')
    throw new TypeError('"options" argument must be a string or an object');
  else
    options = Object.create(options);

  // For backwards compat do not emit close on destroy.
  options.emitClose = false;
  options.autoDestroy = false;

  WritableStream.call(this, options);

To elaborate on this, I believe @sdir is suggesting to add options.autoDestroy = false; to SFTP.js (refer to lines 3387-3400), which is a part of the ssh2 package. In the context of liximomo/vscode-sftp, it looks like this is part of ssh2-streams, and you’d want to update:

~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js

I can confirm that this also works to resolve the issue when running VS Code 1.56.0. image You’ll find the NodeJS release notes here which documents the change in default behaviour of autoDestroy. It was changed in this commit as part of this pull request. Per the comment changes as part of that commit, streams are now closed when an error event is emitted, unless the autoDestroy option is set to false when first creating the stream.

Thanks! It’s now working perfectly! At the same time, the following problems are also solved

When I use the Upload Folder directives to upload a folder, some files will fail to upload. This situation did not exist before VSCode was updated.

This workaround works indeed. But I think should update code somewhere in this extension (vscode-sftp),may be set default options for calling the function WriteStream() in sftp.js.

options.autoClose default false but autoDestroy not change. Maybe a bug for ssh-stream library.

stream.Writable Change autoDestroy option default to true in Nodejs V14. add code

function WriteStream(sftp, path, options) {
  if (options === undefined)
    options = {};
  else if (typeof options === 'string')
    options = { encoding: options };
  else if (options === null || typeof options !== 'object')
    throw new TypeError('"options" argument must be a string or an object');
  else
    options = Object.create(options);

  // For backwards compat do not emit close on destroy.
  options.emitClose = false;
  options.autoDestroy = false;

  WritableStream.call(this, options);

To elaborate on this, I believe @sdir is suggesting to add options.autoDestroy = false; to SFTP.js (refer to lines 3387-3400), which is a part of the ssh2 package.

In the context of liximomo/vscode-sftp, it looks like this is part of ssh2-streams, and you’d want to update:

~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js

I can confirm that this also works to resolve the issue when running VS Code 1.56.0.

image

You’ll find the NodeJS release notes here which documents the change in default behaviour of autoDestroy. It was changed in this commit as part of this pull request. Per the comment changes as part of that commit, streams are now closed when an error event is emitted, unless the autoDestroy option is set to false when first creating the stream.

Thanks! It’s now working perfectly!

Good solutions! It`s not a bug is feature

Editing the file: ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js change the line 388: if (code === STATUS_CODE.OK) { to: if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) { Reload vscode It is not the most correct option but it works.

Thanks! But there are other failures and I’m not willing to downgrade my vscode. Since this extension seems not maintained any more, I’m trying some alternatives right now the ‘ftp-sync’(https://github.com/lukasz-wronski/vscode-ftp-sync) I will update more info later


It sucks… I haven’t found any ok alternatives

I’m guessing with the repo untouched for 2 years we’ll have to hope that the next VSCode update unbreaks it.

WTF!?! …and there is no alternative that’s just as good. That’s why I’m always weary and despise the plugin/extension model.

You say that, but a lot of other people who say that also never donated to the owner of this repo. If I had to guess, they probably abandoned it because of all the issues people kept posting that were entirely connection/configuration related. That’d be exhausting work to do for free.

+1

Same issue here under version 1.12.9, pop up “No such file error” while uploading file to remote, but actually the file has been successfully uploaded.

Be careful with it, some times, when you update file, is can come empty. And if update folder, some files can be empty, some files may contain text from other files. I downgraded my VSCode to previous version

Thanks for your remind, this issue is annoying…