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

ReferenceError: reentry is not defined #29

Open
aliabbas90 opened this issue May 29, 2018 · 4 comments
Open

ReferenceError: reentry is not defined #29

aliabbas90 opened this issue May 29, 2018 · 4 comments

Comments

@aliabbas90
Copy link

I am actually encountering a problem while I am trying to upload a file from storage to an FTP server, passing by a triggered node js function.

So, every time a file, with a specific name, is uploaded to Firebase storage, this file should automatically be uploaded to the FTP server. To do that, I am using promise-ftp. I am able to connect to the server but when it comes to upload files, I am faced with a connection timeout.

But, when I execute the js script locally without passing by a trigger, the file is successfully uploaded.

My promise-ftp script that I tried locally looks like :

function test() {
  var ftp = new PromiseFtp();
  const tempFilePath = path.join(os.tmpdir(), '123.pdf');
  ftp.connect({host: 'ftp.aaa-bbbb.ccc', user: 'aaabbb', password: 'pswd123'})
  .then(function (serverMessage) {
    console.log(serverMessage);
    return ftp.put(tempFilePath, 'local.pdf');
  })
  .then(function () {
    return ftp.end();
  })
  .then(() => {
    console.log("Ready to delete");
     // Once the pdf has been uploaded delete the local file to free up disk space.
    fs.unlinkSync(tempFilePath);
  });
}
exports.updateToFTP = functions.storage.object().onFinalize((object) => {
    // [START eventAttributes]
    const fileBucket = object.bucket; // The Storage bucket that contains the file.
    const filePath = object.name; // File path in the bucket.
    const contentType = object.contentType; // File content type.
    const resourceState = object.resourceState; // The resourceState is 'exists' or 'not_exists' (for file/folder deletions).
    const metageneration = object.metageneration; // Number of times metadata has been generated. New objects have a value of 1.
    // [END eventAttributes]

  // [START stopConditions]
  // Exit if this is triggered on a file that is not an image.
  if (resourceState === 'exists') {
    // ignore for deletions
    return
  }
  if (!contentType.startsWith('application/pdf')) {
    return null;
  }
  // [END stopConditions]
  // Get the file name.
  const fileName = path.basename(filePath);
  // get file from bucket.
  const bucket = gcs.bucket(fileBucket);
  const tempFilePath = path.join(os.tmpdir(), fileName);
  var ftp = new PromiseFtp();
  return bucket.file(filePath).download({
    destination: tempFilePath,
  }).then(() => {
    return ftp.connect({host: 'host', user: 'usr', password: 'pwd'})
  }).then(function (serverMessage) {
    console.log(serverMessage);
    return ftp.put(tempFilePath, fileName);
  }).then(function () {
    return ftp.end();
  })
  .then(() => {
    console.log("Ready to delete");
     // Once the pdf has been uploaded delete the local file to free up disk space.
    fs.unlinkSync(tempFilePath);
  }).catch((err) => {
      console.log("Catching error");
      console.log(err)
  });
})

The error is :

ReferenceError: reentry is not defined
    at /user_code/node_modules/promise-ftp/node_modules/@icetee/ftp/lib/connection.js:937:18
    at Timeout._onTimeout (/user_code/node_modules/promise-ftp/node_modules/@icetee/ftp/lib/connection.js:962:9)
    at ontimeout (timers.js:386:11)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

Any idea?

@zacronos
Copy link
Member

I have not seen this error before. As you can see in the stack trace you've provided, the error actually originates within the @icetee/ftp dependency, not promise-ftp itself. I would try posting that error trace as an issue with @icetee/ftp and see if anyone there can help.

@JLRishe
Copy link

JLRishe commented Feb 4, 2021

@zacronos It looks like this bug was fixed in @icetee/ftp around version 1.0.6, but this library is still using version 0.3 of that package.

I observed this error yesterday in a downstream package that depends on yours (ftp-deploy).

@jamaica474
Copy link

Having same issue.

@taylorgibb
Copy link

taylorgibb commented Sep 9, 2021

I am also observing this issue. Seems to be what @JLRishe points out. I have patched promise-ftp to use an updated version of @icetee/ftp (1.0.8) here (https://github.com/taylorgibb/promise-ftp)

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

5 participants