Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created August 13, 2012 17:04
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 briancavalier/3342531 to your computer and use it in GitHub Desktop.
Save briancavalier/3342531 to your computer and use it in GitHub Desktop.
Q + when.js infinite loop, take 2
// `npm install q when`
// `node test.js`
// watch CPU and memory using top
var q, when, d;
q = require('./node_modules/q');
when = require('./node_modules/when');
// Using either gives the same behavior in all cases I've tried
d = q.defer();
//d = when.defer();
// It seems like the next two lines should produce equivalent results,
// but they don't. Using q.when() causes an infinite loop, but using
// d.promise.promiseSend() works.
// Causes infinite loop
q.when(d.promise, when.resolve);
// Works correctly
//d.promise.promiseSend('when', when.resolve);
d.resolve(1).then(console.log, console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment