Skip to content

Instantly share code, notes, and snippets.

@mrvisser
Last active January 1, 2016 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrvisser/8185573 to your computer and use it in GitHub Desktop.
Save mrvisser/8185573 to your computer and use it in GitHub Desktop.

Rather than:

callback(new TFramedTransport(frame));

This could be done:

(function(frame) {
  process.nextTick(function() {
    callback(new TFramedTransport(frame));
  });
})(frame);

And then the state of the receiver does not get borked if callback is bogus.

var i = 0;
while (i < 5) {
process.nextTick(callback);
console.log(i);
i++;
}
function callback() {
throw new Error();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment