Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

When rendering a pass through a response, the callback never gets called on success #12

Open
mikeseghers opened this issue Dec 17, 2013 · 1 comment

Comments

@mikeseghers
Copy link

When I render a pass through the .render(response, callback) method, the callback only gets called when something fails.

I thing the issue is that the "end" event is never emitted when the zip file has been created successfully. I've done some testing, and I've seen that the "end" event on the zip variable is never fired neither.

When I add an zip.emit("end") after adding the signature is added to the zip. Still nothing happens. When i move the zip.on("end", ...) outside of the callback passed to the self.signZip(...) method, my original callback gets called.

here is how I changed the code:

in pass.js:

within the pipe function:

function doneWithImages() {
    if (lastError) {
      zip.close();
      self.emit("error", lastError);
    } else {

//This was moved up
        zip.on("end", function() {
          self.emit("end");
        });
        zip.on("error", function(error) {
          self.emit("error", error);
        });
//End of change
      self.signZip(zip, manifest, function(error) {
        zip.close();
        //the above code was taken from here
      });
    }
  }

within the signZip function:

signManifest(this.template, json, function(error, signature) {
    if (!error) {
      zip.addFile("signature").end(signature);
//The next line was added
zip.emit("end");
    }
    callback(error);
  });
@kgjohnso
Copy link

+1

and thanks @mikeseghers for finding the solution

gongxiancao added a commit to cloudnapps/node-passbook that referenced this issue Aug 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants