Skip to content

Conversation

@inssein
Copy link
Contributor

@inssein inssein commented Oct 14, 2015

Fixes #645

@LinusU
Copy link
Collaborator

LinusU commented Oct 15, 2015

I don't understand, how does this make sure that callbacks only fire once? Could you please explain your code :)

@inssein
Copy link
Contributor Author

inssein commented Oct 15, 2015

@LinusU I just wrote a simple test, and ran it across 4 different versions of node. Looks like it never worked, or I am missing something.

var done = function() {
  console.log('done');
};

var fn = function(ctx, done) {
  done();
};

2 == fn.length ? fn('test', done) : fn('test'), done();

The above code will print done twice. Once by going through fn(), and once by being called at the end of the last line. This breaks the test for me as /jpeg and /render will try to send the result twice.

@LinusU
Copy link
Collaborator

LinusU commented Oct 15, 2015

Cool, yes I have seen this behaviour as well actually

@inssein
Copy link
Contributor Author

inssein commented Oct 19, 2015

@LinusU what's the process on getting this merged?

@LinusU
Copy link
Collaborator

LinusU commented Oct 19, 2015

Merging now, sorry for the delay

LinusU added a commit that referenced this pull request Oct 19, 2015
add helper function to execute test and only fire callback once
@LinusU LinusU merged commit 8d81ede into Automattic:master Oct 19, 2015
@inssein
Copy link
Contributor Author

inssein commented Oct 19, 2015

@LinusU thanks!

@LinusU
Copy link
Collaborator

LinusU commented Oct 19, 2015

Thank you, help is always appreciated!

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

Successfully merging this pull request may close these issues.

2 participants