Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ftp.get() hangs for 60 seconds in node v10, but not in node v8 #228

Closed
broofa opened this issue Oct 4, 2018 · 5 comments
Closed

ftp.get() hangs for 60 seconds in node v10, but not in node v8 #228

broofa opened this issue Oct 4, 2018 · 5 comments

Comments

@broofa
Copy link

broofa commented Oct 4, 2018

Specifically, when I run the test case below (fetching a single file from a local FTP server), it takes ~53msecs on node v8, but 60000msecs on node 10.

Exact console output listed below as well.

const Ftp = require('ftp');

const host = '192.168.1.201';
const user = 'anonymous';
const fileName = 'axis.dg';

let client = new Ftp();

client.on('ready', () => {
  console.time('get()');
  client.get(fileName, (err, stream) => {
    stream.on('end', () => {
      console.timeEnd('get()');
      client.destroy();
    });
  });
});

client.connect({host, user});

The exact console output, if it helps:

$ nvm use 8
Now using node v8.11.4 (npm v5.6.0)

$ node test.js
get(): 53.476ms

$ nvm use 10
Now using node v10.11.0 (npm v6.4.1)

$ node test.js
get(): 60081.924ms
@kingeaglewang
Copy link

After update node version from 8.9.2 to 10.2.0, I also encounter this problem.
But don't know why?

@broofa
Copy link
Author

broofa commented Jan 3, 2019

@kingeaglewang: Note that this module appears to have been abandoned (3+ years since a new version published, 1+ years since a contributer has commented on an issue).

I've switched to the basic-ftp module, and have been working with the author on a new release (see the feature/v3 branch).

Edit: Readers may also be interested in @icetee's fork at https://www.npmjs.com/package/@icetee/ftp

@zhang110912
Copy link

I also encounter this problem after upgrade node version to 10.16.5,
Is there a bug triggered on 10.x node version ?
any suggestion will be appreciated!

@std4lqi
Copy link

std4lqi commented Dec 13, 2019

I did some investigation. Node.JS v10 changed to use the way for socket clean up at EOF.

Node.JS v8: Find onread() in https://github.com/nodejs/node/blob/v8.16.2/lib/net.js.

Node.JS v10 Find onStreamRead() in https://github.com/nodejs/node/blob/v10.17.0/lib/internal/stream_base_commons.js.

I'm not sure about the actual difference yet.

But I noticed in connection.js, this node-ftp library sends MODE S when all data is received, switching backing to stream mode. It might be required by compress mode, switching to MODE Z already, and switching back to MODE S.

After commenting out the line of self.send('MODE S'..., keeping _emit('end') and _emit('close'), I don't have 2-min hang on Node.JS v10 any more.

function ondone() {
        console.log(`${Date.now()} done=${done} lastreply=${lastreply}`);
      if (done && lastreply) {
        self._send('MODE S', function() {
          source._emit('end');
          source._emit('close');
        }, true);
      }
    }

@broofa
Copy link
Author

broofa commented Apr 24, 2021

@mscdex Time to archive this repo / hand off ownership to someone else? (... conspicuously not volunteering, however. 😝 )

@broofa broofa closed this as completed Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants