Skip to content

Callback not called in .list when ECONNRESET #16

Description

@coyotte508

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions