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

Callback not called in .list when ECONNRESET #16

Open
coyotte508 opened this issue May 17, 2020 · 0 comments
Open

Callback not called in .list when ECONNRESET #16

coyotte508 opened this issue May 17, 2020 · 0 comments

Comments

@coyotte508
Copy link

coyotte508 commented May 17, 2020

After creating a ftp, doing many operations on it, I get this:

Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}

This is from ftp.on('error', ...).

However the .list callback wasn't called at all. It's never called, and my logic just halts.

Here's where I call .list:

  return await new Promise<Array<{name: string, type: string}>>((resolve, reject) => {
      console.log("call underlying list", pathStr);
      this._ftp.list(pathStr, (err: Error, list: Ftp.ListingElement[]) => {
        if (err) {
          console.log("ftp list ended with error");
          reject(err);
        }
        console.log("ftp list ended with success");
        resolve(list);
      });
    });

Here's where I handle the more general error event, before the connection event:

return await new Promise<string>((resolve, reject) => {
      this._ftp.on("ready", () => {
        this._connected = true;
        this._connecting = false;
        console.log("ftp connected and ready");
        resolve("/");
      });
      this._ftp.on("error", err => {
        this._connected = false;
        this._connecting = false;
        console.error("ftp error", err);
        reject(err);
      });
      this._ftp.on("close", () => {
        console.log("ftp closed");
        this._connected = false
      });
      this._ftp.on("end", () => {
        console.log("ftp end");
        this._connected = false
      });
      this._ftp.connect(this._credentials);
    });

And here's the log of my application:

call underlying list /public/IMR_Donnees_Saisies/tc/flux/2020/05/12/9401/1618
ftp error Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}
ftp closed

So ftp does emit the error and close events, but the callback of list is never called.

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

1 participant